private static void processConjunctionMarker(final Class<? extends ConnectiveStep> markerClass, final Traversal.Admin<?, ?> traversal) {

        final List<Step> steps = traversal.getSteps();
        for (int i = 0; i < steps.size(); i++) {
            final Step step = steps.get(i);
            if (step.getClass().equals(markerClass)) {
                final ConnectiveStep<?> currentStep = (ConnectiveStep) step;
                if (currentStep.getLocalChildren().isEmpty()) {
                    Traversal.Admin<?, ?> connectiveTraversal;
                    currentStep.addLocalChild(connectiveTraversal = __.start().asAdmin());
                    for (int j = i - 1; j >= 0; i--, j--) {
                        final Step previousStep = steps.get(j);
                        if (legalCurrentStep(previousStep)) {
                            connectiveTraversal.addStep(0, previousStep);
                            traversal.removeStep(previousStep);
                        } else break;
                    }
                    i++;
                    currentStep.addLocalChild(connectiveTraversal = connectiveTraversal(connectiveTraversal, currentStep));
                    currentStep.clearLabels();
                    while (i < steps.size()) {
                        final Step nextStep = steps.get(i);
                        if (legalCurrentStep(nextStep)) {
                            if (nextStep.getClass().equals(markerClass) &&
                                    ((ConnectiveStep) nextStep).getLocalChildren().isEmpty()) {
                                final ConnectiveStep<?> nextConnectiveStep = (ConnectiveStep<?>) nextStep;
                                currentStep.addLocalChild(connectiveTraversal = connectiveTraversal(connectiveTraversal, nextConnectiveStep));
                            } else {
                                connectiveTraversal.addStep(nextStep);
                            }
                            traversal.removeStep(nextStep);
                        } else break;
                    }
                    if (currentStep instanceof OrStep) {
                        currentStep.getLocalChildren().forEach(t -> processConjunctionMarker(AndStep.class, t));
                    }
                }
            }
        }
    }
ConnectiveStrategy rewrites the binary conjunction form of {@code a.and().b} into a {@link AndStep} of
{@code and(a,b)} (likewise for {@link OrStep}).
<p/>

@author Marko A. Rodriguez (http://markorodriguez.com)
@author Daniel Kuppitz (http://gremlin.guru)
@example <pre>
__.has("name","stephen").or().where(__.out("knows").has("name","stephen"))   // is replaced by __.or(__.has("name","stephen"), __.where(__.out("knows").has("name","stephen")))
__.out("a").out("b").and().out("c").or().out("d")                            // is replaced by __.or(__.and(__.out("a").out("b"), __.out("c")), __.out("d"))
__.as("a").out().as("b").and().as("c").in().as("d")                          // is replaced by __.and(__.as("a").out().as("b"), __.as("c").in().as("d"))
</pre>
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ConnectiveStrategy.java