while (!previousStep.equals(EmptyStep.instance()) && !(previousStep instanceof PropertiesStep) && !(previousStep instanceof VertexStep)) {
previousStep = previousStep.getPreviousStep();
// TODO: check for not filtering/sideEffect steps and throw an exception?
}
if (previousStep instanceof VertexStep) {
VertexStep vertexStep = (VertexStep) previousStep;
if (vertexStep.getReturnClass().equals(Edge.class)) {
localRangeStep.setDirection(vertexStep.getDirection());
} else {
throw new IllegalStateException("LocalRangeStep must follow a VertexStep that produces edges, not vertices");
}
} else if (previousStep instanceof PropertiesStep) {
// do nothing, all is good