Data tree problem

Hello, I have a problem with trees. I have some surfaces grouped into 4 branches - each branch marks one of edges of a rectangle where surfaces start. Structure is {x;y} where x is index of curve and y is edge of a rectangle.

I know the description is messy, but heres a definition:

TREES_PROBLEM.gh (29.6 KB)

What i want to do is take each edge of each surface in each branch and “project” (in z axis) it to all other surfaces in THAT BRANCH, and split each surface afterwards. I thought of numerous ways but what i ended up doing was:

  1. get each surface edges
  2. project all curves to xy plane
  3. extrude lines
  4. find intersection between initial surfaces and extrusions.

The thing is number of items in corresponding branches are not equal between initial surfaces and extruded lines. I grafted the extrusions. As far as i understand a structure of:

{x;y} for surfaces and {x;y;z} for extrusions should create corresponding intersections - so all intersections for each surface in {x;y} with a corresponding z. In the meantime I get strange results.

I’d appreciate any help.
Thanks, have a good one.