~~~ Scala
if (isTerminated) dump(todo)
else if (todo.nonEmpty) invokeAll(todo, newState)
~~~