Creating a data tree from a list of indices



hello good people, I am trying to find a good way to create a data tree, from a set of geometries I have, sorted according to a list of indices or indexes I have, giving that I have duplicate numbers in the index list I expect to have branches with multiple values, but I can’t find a way to that .
thanks in advance


Is this what you want?


exactly, big thanks