Added findClosestAncestorByType()