find the lowest common ancestor in a tree