Create tree branch from duplicate items

Hello All,

I have a list here of layer names for every single surface I have in my file. I wonder how I can create a tree where I can sort the 3 branches for the 3 different elements here

So that the tree would have

{0:0}
0 apple
1 apple
2 apple

{0:1}
0 orange
1 orange

{0:2}
0 cherry
1 cherry

Thank you!

mindex_2023Feb17a
mindex_2023Feb17a.gh (6.5 KB)

This has many, many applications:

1 Like

Thank you for the quick reply Joseph and your continuous support!!