fixed findAncestorByType()