public default Barrier determineBarrierStep(final Traversal.Admin<S, V> traversal) {
        final List<Step> steps = traversal.getSteps();
        for (int ix = 0; ix < steps.size(); ix++) {
            final Step step = steps.get(ix);
            if (step instanceof Barrier && !(step instanceof LocalBarrier)) {
                final Barrier b = (Barrier) step;

                // when profile() is enabled the step needs to be wrapped up with the barrier so that the timer on
                // the ProfileStep is properly triggered
                if (ix < steps.size() - 1 && steps.get(ix + 1) instanceof ProfileStep)
                    return new ProfilingAware.ProfiledBarrier(b, (ProfileStep) steps.get(ix + 1));
                else
                    return b;
            }
        }
        return null;
    }
Determines the first non-local {@link Barrier} step in the provided traversal. This method is used by {@link GroupStep}
and {@link GroupSideEffectStep} to ultimately determine the reducing bi-operator.

@param traversal The traversal to inspect.
@return The first non-local barrier step or {@code null} if no such step was found.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Grouping.java