The shovel_machine function has code that looks like this...
for (u32 i = 0; i < MAX_DEPTH; i++) {
....
}
My understanding of the code is that if a level is empty (start_loc == end_loc), then all other levels are going to be empty. So the loop should end once this stage is reached.
(I am aware that this is not a performance issue.)