if (TraversalHelper.isLabeled(toStep))
toStep.getPreviousStep().setLabel(toStep.getLabel());
TraversalHelper.removeStep(toStep, traversal);
} else {
// WHILE DO SEMANTICS
final JumpStep fromStep = (JumpStep) TraversalHelper.getStep(toStep.getJumpLabel(), traversal);
final List<Step> stepsToClone = TraversalHelper.isolateSteps(toStep, fromStep);
stepsToClone.forEach(stepToClone -> TraversalHelper.removeStep(stepToClone, traversal));
for (int i = 0; i < ((short) toStep.getJumpLoops().getValue0() + 1); i++) {
for (int j = stepsToClone.size() - 1; j >= 0; j--) {
try {
final Step clonedStep = stepsToClone.get(j).clone();
TraversalHelper.insertStep(clonedStep, traversal.getSteps().indexOf(fromStep) + 1, traversal);
} catch (final CloneNotSupportedException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
}
// System.out.println(toStep + "::" + fromStep + "::" + fromStep.jumpLabel);
TraversalHelper.removeStep(TraversalHelper.getStep(fromStep.getJumpLabel(), traversal), traversal); // identity marker
TraversalHelper.removeStep(toStep, traversal); // left hand jump
TraversalHelper.removeStep(fromStep, traversal); // right hand jump
if (TraversalHelper.isLabeled(toStep))
toStep.getPreviousStep().setLabel(toStep.getLabel());
TraversalHelper.removeStep(toStep, traversal);