Introduction
In our last lesson, we investigated how Grasshopper handles operations between lists of different lengths by using the data matching rules: Shortest List, Longest List, and Cross Reference. A crucial point was that when dealing with complex data, these rules are applied on a branch-by-branch basis. This raises a critical question: how do we control the branch structure itself? To truly master parametric modeling, simply matching data isn't enough; we must be able to sculpt the data structures with intention.
This lesson delves into that foundational topic. We will formally deconstruct the anatomy of a Data Tree, Grasshopper's unique system for organizing information. You will learn to identify its core components—paths, branches, and items—and visualize its hierarchy. Then, we will equip you with the three most fundamental tools for manipulating this structure: Flatten, Graft, and Simplify. By the end of this lesson, you will have a clear mental model of how data is organized and the primary means to reshape it, setting the stage for more advanced data management.
1. The Anatomy of a Data Tree
At first glance, the output of many Grasshopper components can seem perplexing. A simple operation like subdividing a surface doesn't just produce a jumble of points; it yields a highly organized, hierarchical collection of data. This structure is called a Data Tree. Your background in information and communications technology (ICT) gives you a head start here, as the concept is analogous to hierarchical file systems or tree data structures in programming.
To build a robust understanding of the terminology, let's watch an excellent overview from the ParametricCamp channel. The presenter, Jose Luis, clearly explains each component of a data tree.
5.2 Data Structures in Grasshopper - Intro to Parametric Modeling
This video provides a clear, conceptual introduction to Data Trees, using a surface division example to illustrate the key terms.
Please watch from the main explanation. As you watch, focus on how he defines and differentiates the following five terms: Data Tree: The overall container. Branch: A sub-list within the tree. Path: The unique address or "name" of a branch, like {0;0;1}. Item: A single piece of data (e.g., a point, a number). Index: An item's position within its branch, starting from zero.
Let's synthesize those concepts. Think of a data tree as a digital filing cabinet for your geometric or numerical data.
- Items are the individual files—a single coordinate, a curve, a number. They are the fundamental units of data.
- A List is the collection of all items within a single drawer.
- Branches are the drawers themselves. Each branch holds a list of items and is identified by a unique address.
- Paths are the labels on the drawers (e.g.,
{0;1}). They define the address of a branch within the tree's hierarchy. The numbers in a path indicate levels of nesting, much like folders and subfolders. - Indices are the ordered positions of items within a list (i.e., inside a drawer), always starting from 0.

The primary tool for inspecting this structure is the Param Viewer component (found under Params > Util). When you connect a data stream to it, you can right-click and select "Draw Tree" to get a visual representation of the branching structure, which is invaluable for debugging your definitions. The standard Panel component also displays the full path and index information, as you saw in the video.
2. Fundamental Tree Operations: Flatten, Graft, and Simplify
Understanding the structure of a data tree is the first step; manipulating it is the second. Grasshopper provides three essential operations that allow you to change the tree's hierarchy without altering the items themselves. These operations are so fundamental that they are available both as standalone components (under Sets > Tree) and as options in the right-click menu of most component inputs and outputs.
The following reading from an interactive textbook by TU Delft provides a concise explanation of these three operations.
Lesson 3 - Data structures — Rhino Grasshopper Open Access ...
This resource clearly illustrates the effect of Flatten, Graft, and Simplify on a sample data tree. The diagrams make the transformations easy to grasp.
Please read the section Manipulating Data Trees. Pay close attention to the diagrams showing the "before" and "after" state of the data tree for each of the three operations.
Let's expand on that reading using our filing cabinet analogy.
-
Flatten (
Flatten Tree): This is the most drastic operation. It removes all branching information, collapsing the entire data tree into a single list in a single branch ({0}).- Analogy: Taking all the files out of every drawer in the cabinet and putting them into one giant pile on the floor. You still have all the files, but their original grouping is lost.
- Use Case: This is useful when you no longer care about the original structure and want to treat all items as a single collection, for example, to find the average position of all points in a grid. Use it with caution, as the structural information cannot be recovered.
-
Graft (
Graft Tree): This operation does the opposite of Flatten. It creates a new branch for every single item in the tree.- Analogy: Taking every single file from your cabinet and putting each one into its own brand-new, individually labeled drawer. This dramatically increases the complexity of your filing system.
- Use Case: Grafting is essential when you want to apply an operation to every item individually in combination with another data set. For instance, if you want to draw a line from 3 "base" points to each of 50 "target" points, you would graft the list of base points so that the
Linecomponent's data matching rule (e.g., Longest List) applies the entire list of target points to each individual base point.
-
Simplify (
Simplify Tree): This is a "housekeeping" operation. It removes any redundant or overlapping parts from the branch paths without changing the actual branching structure. If all branches share a common "prefix" in their path (e.g., every path starts with{0;0}), Simplify will remove it.- Analogy: Your drawers are labeled "Sales Dept -> Q3 -> Drawer A", "Sales Dept -> Q3 -> Drawer B", etc. If all drawers are in the Sales Dept and for Q3, you can simplify the labels to just "A", "B", etc., without moving the drawers.
- Use Case: After several operations, data tree paths can become unnecessarily complex (e.g.,
{0;0;0;1},{0;0;0;2}). Simplifying makes the paths easier to read and manage, which is crucial before performing advanced operations like retrieving specific branches. It's good practice to simplify trees whenever their structure has stabilized.

Conclusion
In this lesson, we established the theoretical foundation for one of Grasshopper's most powerful—and often most confusing—features: the data tree. By breaking it down into its constituent parts and understanding the tools to reshape it, you've taken a significant step toward creating complex, predictable parametric models.
Here are the key takeaways:
- All data in Grasshopper is stored in Data Trees, a hierarchical structure of branches that contain lists of items.
- Each branch has a unique address called a path, and each item within a branch has an index starting from 0.
- The Param Viewer is an essential tool for visualizing and debugging the structure of your data trees.
- Flatten collapses a tree into a single list, destroying its hierarchy.
- Graft creates a new branch for every item, increasing the tree's complexity.
- Simplify cleans up the branch paths by removing redundant information, making the tree easier to work with.
In our last lesson, you learned how to set data matching rules. Now, you know how to manipulate the very structure that these rules operate on. In our next lesson, we will combine these skills and learn how to perform surgical strikes on our data trees—retrieving specific branches and items to use in downstream operations.