private static int labelCount(final String label, final Traversal.Admin<?, ?> traversal) {
        int count = 0;
        for (final Step step : traversal.getSteps()) {
            if (step.getLabels().contains(label))
                count++;
            if (step instanceof TraversalParent) {
                count = count + ((TraversalParent) step).getLocalChildren().stream().map(t -> labelCount(label, t)).reduce(0, (a, b) -> a + b);
                count = count + ((TraversalParent) step).getGlobalChildren().stream().map(t -> labelCount(label, t)).reduce(0, (a, b) -> a + b);
            }
        }
        return count;
    }
{@code PathProcessStrategy} is an OLAP strategy that does its best to turn non-local children in {@code where()}
and {@code select()} into local children by inlining components of the non-local child. In this way,
{@code PathProcessStrategy} helps to ensure that more traversals meet the local child constraint imposed on OLAP
traversals.

@author Marko A. Rodriguez (http://markorodriguez.com)
@example <pre>
__.select(a).by(x)               // is replaced by select(a).map(x)
__.select(a,b).by(x).by(y)       // is replaced by select(a).by(x).as(a).select(b).by(y).as(b).select(a,b)
__.where(as(a).out().as(b))      // is replaced by as(xyz).select(a).where(out().as(b)).select(xyz)
__.where(as(a).out())            // is replaced by as(xyz).select(a).filter(out()).select(xyz)
</pre>
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathProcessorStrategy.java