Selfintersecting sweep issue

Hello,

With Dynamo, I would like to generate a sweep from a series of points.
I managed to do so for points that form a non selfintersecting polycurve.
However, I also have selfintersecting polycurves.
Is there a function in Dynamo to remove this loops in the polycurve?
Or a function that could make a sweep regardless of selfintersecting paths?

Thanks,

Merijn Vanalderweireldt