link.getAncestors()

Return an array of all the ancestors of this link starting from the immediate parent all the way up to the most distant ancestor.