Get your Curve start and endpoints.
Flatten the list and group common points (list.groupbykey where the list and key are the same.
Discard groups with less than three elements in them.
Find which lines in the first list have those points in them. Those are the branching points.
Now you can start with those curves and use a group curves method to find the polycurve from each branch point.