Factor out finding of the next extrusion move
Factor out finding of the next extrusion move

This was some repeating code that was both duplicate and inefficient.

Contributes to issue CURA-8708.

Ultimaker/CuraEngine,Ultimaker/CuraEngine