private static void handleChildStepCollection(final Stack<Step<?, ?>> processingStack, final List<Step<?, ?>> collectionList, final Step<?, ?> childStep) {
        if (TraversalParent.class.isAssignableFrom(childStep.getClass()) || LambdaHolder.class.isAssignableFrom(childStep.getClass())) {
            collectionList.add(childStep);
        }
        processingStack.push(childStep);
    }
Small helper method that collects desired children (i.e., steps that are either traversal parents or LambdaHolders).
All children are added to the stack such that they are also processed.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategy.java