Solution to find first common ancestor in binary tree