Function infinitely loop

I have three functions: maze_step maze_forward maze_backtrack

maze_step Is supposed to pick between maze_forward & maze_backtrack depending on if there are any unvisited nodes available in one of the axes. If there are, it should pick maze_forward. If not it should pick maze_backtrack. This should keep happening up until it arrives back at the start node.

At that point it should not be able to pick either maze_forward or maze_backtrack and run the maze_end_generation function.

When I use # to remove the automatic triggering of each other and run the command manually while using execute commands with the same conditions but that run a say command instead of function. It all works perfectly and it's correctly telling me which command to execute next.

I tried using schedule to delay each execution of maze_step to allow the server to slow everything down a bit, but it's still making mistakes.

Continue to help post