Sorting Curves of the Same Z-value Into the Same Branch

I have a couple of curves that are already sorted based on z value. however I am trying to sort the curves that have the same z value onto the same branch, bringing my branch count from 18 to 11 (I think).
z value branch sort.gh (41.4 KB)

this is one way

z value branch sort_inno.gh (49.7 KB)

Hehe took me to long to figure it out.

Nothing new here, just by plane:

Same, but actually worse idea: