What I need is to do a polynomial fit of the descending part of the large curve in blue (hysteresis curve) from point A to point B.
However, the curve is not continuus, and minor loops inside are created. In the figure you see the arrows and numbers indicating sequence.
So, I need to be able to eliminate all the inside loops and only fit the large one. Of course, the position and number of the minor loops is here given as an illustration and in reality there is much more of them.