/** * Determine if the traversal has any of the supplied steps of an assignable class in the current * {@link Traversal} and its child traversals. * * @param stepClasses the step classes to look for * @param traversal the traversal in which to look for the given step classes * @return <code>true</code> if any step in the given traversal (and its child traversals) is an * instance of a class provided in <code>stepClasses</code>, otherwise <code>false</code>. */ public static boolean hasStepOfAssignableClassRecursively( final Collection<Class> stepClasses, final Traversal.Admin<?, ?> traversal) { if (stepClasses.size() == 1) return hasStepOfAssignableClassRecursively(stepClasses.iterator().next(), traversal); for (final Step<?, ?> step : traversal.getSteps()) { if (IteratorUtils.anyMatch( stepClasses.iterator(), stepClass -> stepClass.isAssignableFrom(step.getClass()))) { return true; } if (step instanceof TraversalParent) { for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren()) { if (hasStepOfAssignableClassRecursively(stepClasses, globalChild)) return true; } } } return false; }