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 apple
1 apple
2 apple

0 orange
1 orange

0 cherry
1 cherry

Thank you!

mindex_2023Feb17a (6.5 KB)

This has many, many applications:

1 Like

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