private static void iterateParents( Operator<?> operator, Function<Operator<?>> function, Set<Operator<?>> visited) { if (!visited.add(operator)) { return; } function.apply(operator); if (operator.getNumParent() > 0) { for (Operator<?> parent : operator.getParentOperators()) { iterateParents(parent, function, visited); } } }
public static void iterateParents(Operator<?> operator, Function<Operator<?>> function) { iterateParents(operator, function, new HashSet<Operator<?>>()); }