common ancestor problem + test for generating the tree