Unexpect list_to_tree() behavior (GH Python)

Hello, I have a GH Python component inside of which I have a nested list. The list may look something like this (although I’m outputting multiple lists like this one):

[[5], [], [8, 9], [5, 9], [], [0, 8, 3, 9], [], [], [5, 9, 2], [5, 8, 3, 2]]

My input data comes in trees, say 27 branches {0} through {26}. Now, the weird part.

In the python component, I’m creating nest lists that look like the above. If I output the lists, then I get 27 branches, as expected, since the component runs 27 times. However, if I convert my nested lists into a Tree, then I get 10 branches only (which is the number of sub-branches that I want). If I had 27 input branches, then I would like my output tree to be {A;B} with A=27 and B=10.

Here’s the code. What am I doing wrong?

import rhinoscriptsyntax as rs
import ghpythonlib.treehelpers as th 

temp_connections = []
connections = []
nodes = []

for i in range(l):
    for j in range(len(n1)):   
        if i == n1[j]:

    for k in range(len(n2)):
        if i == n2[k]:
    connections = temp_connections[:]
    del temp_connections[:]

nodes_Tree = th.list_to_tree(nodes,True,source=[0,0])

a = nodes_Tree

I’m also attaching the gh file. Thanks for your help!
tree_question.gh (14.9 KB)