Implement getAncestorPath for commonAncestor.js