How the Tree Branches are added in GH?

I noticed when doing some operation for list/tree, there will be an added empty layer. I am tring to figure out the logic behind that, but didn’t get a clue.

Think of it as some sort of history, keeping track of how many different operations have already been performed on a data set. In your case, you start at {0}, and then shift the list, which adds another 0 or historical state, and the tree becomes {0;0}!

In the same logic, it can be argued that simplifying data trees, equals purging or deleting the data history in question. This is why many seasoned Grasshopper users don’t use simplify, but rather more elaborate tree management strategies (e.g. pruning, trimming, etc.) that allow you to keep the history, and thus better control over the data.

Keeping the data as long as possible is important. Many times, much later in the definition that organization pays off.

1 Like

Thank you, the way of thinking you suggested is very helpful! Let me extend my question. I use python to do list operation a lot. The different results from a same resource will cause problem in this case. Any suggestions?


Thank you Scott! I extended the question as shown above.

Yes, in the scripting components you’d need to manage this yourself.

1 Like


From your post above, the first case works. Even though you’re inputting a DataTree, it only has one branch so technically it is just a list.

For the second case, you will need to convert back to a DataTree before output. This will give your output data the same tree structure as your input data.

If you want a flat list, you can set the output to Flatten or if you want to flatten it in code you can use the DataTree.Flatten() method.

For the third case, you’re inputting a simplified tree (branches do not share a common “trunk”), so this needs to be handled specially.

Further explanation about dealing with simplified DataTrees here:

and here:

Edit - here is the gh definition from above: (9.4 KB)


1 Like

Thank you Kevin, it is very helpful