How to fix dirty polylines?

Here’s one way:
clean_polylines.gh (16.4 KB)
needs this component:
Topologizer.gha (19 KB)