update condition to find Lowest Common Ancestor