public static void reIdSteps( final StepPosition stepPosition, final Traversal.Admin<?, ?> traversal) { stepPosition.x = 0; stepPosition.y = -1; stepPosition.z = -1; stepPosition.parentId = null; Traversal.Admin<?, ?> current = traversal; while (!(current instanceof EmptyTraversal)) { stepPosition.y++; final TraversalParent parent = current.getParent(); if (null == stepPosition.parentId && !(parent instanceof EmptyStep)) stepPosition.parentId = parent.asStep().getId(); if (-1 == stepPosition.z) { final int globalChildrenSize = parent.getGlobalChildren().size(); for (int i = 0; i < globalChildrenSize; i++) { if (parent.getGlobalChildren().get(i) == current) { stepPosition.z = i; } } for (int i = 0; i < parent.getLocalChildren().size(); i++) { if (parent.getLocalChildren().get(i) == current) { stepPosition.z = i + globalChildrenSize; } } } current = parent.asStep().getTraversal(); } if (-1 == stepPosition.z) stepPosition.z = 0; if (null == stepPosition.parentId) stepPosition.parentId = ""; for (final Step<?, ?> step : traversal.getSteps()) { step.setId(stepPosition.nextXId()); } }