We're getting close :)

Here, I am still bothered by this very large nesting and indentation. Could the body of the `then` and `else` parts be extracted as functions, e.g., `GenLastLevelNextLevelCall` and `GenIntermediateLevelNextLevelCall`? (or better names)