In the case of nested boxes, all arrows on the inside boxes are tried first. If none of them can be taken, then higher-level arrows are tried. This continues until the highest level is reached. If no arrows can be taken at that level, the code finishes executing, i.e., the function returns.