private void IterateCommands(CommandIterationHandler iteration) { if (Commands.Count > 0) { int current = 0; while (current < Commands.Count) { Command command = Commands[current]; CommandResult result = iteration(command); switch (result) { default: current++; break; case CommandResult.Previous: current--; break; } } } }