Implemented Lowest Common Ancestor method