Replace Paths for flipping a tree structure

Hi,
I want to flip the order of the branches in my data tree holding a point cloud with an {A= Layer;B= Curve} structure (that I would very much like to maintain)

So I’ve extracted paths, reversed the list, and then used “Replace Path” to reorder the data. At first glance, this seems to work: the last branch has become the first…

However,

  • in the initial tree, Layer {4} has 3737 Curves and Layer {5} 5199,
  • in the flipped tree Layer {4} is now holding 3617 Curves and Layer {5} has now 5319 Curves.

The sum remains the same, but what I want is: Layer {4} 5199 Curves and Layer {5} 3737.

What am I doing wrong?

Also cannot ReplacePath_unevenvalues.gh (423.8 KB)
reorder the paths manually because there are actually multiple branches at the 1st level (A)

Thanks for any tips!


ReplacePath_unevenvalues_re.gh (417.8 KB)

Thank you so much @HS_Kim, this works well!