public static void iterateParents(Operator<?> operator, Function<Operator<?>> function) {
    iterateParents(operator, function, new HashSet<Operator<?>>());
  }
Starting at the input operator, finds the last operator in the stream that
is an instance of the input class.

@param op the starting operator
@param clazz the class that the operator that we are looking for instantiates
@return null if no such operator exists or multiple branches are found in
the stream, the last operator otherwise
ql/src/java/org/apache/hadoop/hive/ql/exec/OperatorUtils.java