Looking for the nearest ancestor of the two nodes of the binary tree