added utility method findAncestorByType()