How to trim a tree to a path level

Hi,
I have a list that has {0},{0;n},{1},{1;n},… and I need to collapse it to only {0},{1},… where {0} contains all elements from {0} and {0;n}.

Not sure what component to use, would appreciate if anyone is able to help.

shift path to an index level.gh (16.2 KB)

Hi @Kyuubimode
You can use topiary flatten from Heron.
Installing via package manager.

2 Likes

try Path Mapper

2 Likes

You should not have a DataTree like that to begin with. It has a jagged branching which causes problems. I suggest you apply the fix upstream where the jagged Tree is created.

1 Like

And yet there are situations, especially using Entwine, where you cannot inflate the branch depth of one tree to match the depth of the other without using the Path Mapper, so whether you do this before or after combing the trees is wholly irrelevant.

In case of a tree with a pattern like yours:


Obviously, PathMapper is a way to go.

1 Like