Implement getClosestCommonAncestor in commonAncestor.js