Iterates over the parent of the node, then the parent's parent, then the parent's parent's parent, until running out of parents.