Merging/union Overlapping Curves

So I’m trying to develop a lattice structure using twisted boxes and extending the edge curves to achieve something similar to Sou Fujimoto’s serpentine pavilion. currently, because ive extended the curves, theres a lot of overlap and the subsequent pipe structure reflects the same overlap.
Is there any way that I can either merge the overlapping curves into a single curve for a smoother brep generation? or union the brep into a nice single piece without those annoying overlap ends showing?

Apologies if I’ve described my problem badly, its my first post

Lattice Script.gh (9.3 KB)