Made changes to the new functions getAncestors and getDescendants