private int getDepth(final Step<?,?> step) {
        return step == null || step instanceof EmptyStep ? 0 : getDepth((Step) step.getTraversal().getParent()) + 1;
    }
A {@code Comparator} that compares steps on the depth of the traversal that they are in.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DepthComparator.java