I'm puzzled. I could change the while-loop to a for-loop. But I don't think it can be included in the nested for-loop.

The for-loop is inside the while-loop so that if the for-loop produces an override which returns `NotImplemented` it will be run again. I don't see how to do this with one loop or something more hackish.