private static boolean isOptimizable(final Step step) {
        return ((step instanceof VertexStep && ((VertexStep) step).returnsVertex()) ||
                (step instanceof PropertiesStep && PropertyType.VALUE.equals(((PropertiesStep) step).getReturnType()))) && (step.getTraversal().getEndStep().getLabels().isEmpty() || step.getNextStep() instanceof CountGlobalStep);
    }
Checks whether a given step is optimizable or not.

@param step the step to check
@return <code>true</code> if the step is optimizable, otherwise <code>false</code>
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/AdjacentToIncidentStrategy.java