# Split tree using masks

**URL:** <https://discourse.mcneel.com/t/split-tree-using-masks/178628>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [March 25, 2024, 9:57am UTC](https://discourse.mcneel.com/t/split-tree-using-masks/178628 "2024-03-25T09:57:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon76319893](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@anon76319893](https://discourse.mcneel.com/u/anon76319893)\
**Post date:** [March 25, 2024, 9:57am UTC](https://discourse.mcneel.com/t/split-tree-using-masks/178628/1 "2024-03-25T09:57:15Z")

</div>

I would like to get automatically the branch which starts always with 0 and sub branch max. In this case the result should give {0;2} branch. I cannot put it straight mask {0;2} since Datatree is variable

Is there any mask to solve it ? or do i need to use tree statistics. I would prefer more smart mask.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/e/b/8eb8728fcce46ada5e424ab8f4bce9b9b352bc37.png)  
[unnamed.gh](https://discourse.mcneel.com/uploads/short-url/5KUyFnfZfjfD6DQTJAofq9FClNS.gh) (6.0 KB)

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/772775_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [March 25, 2024, 10:46am UTC](https://discourse.mcneel.com/t/split-tree-using-masks/178628/2 "2024-03-25T10:46:05Z")

</div>

Here’s one way to do it:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/4/9/9499918c0b0f9246356d306ff00dc79810ee9128.png)

[max\_index\_split\_tree.gh](https://discourse.mcneel.com/uploads/short-url/ajmAO04nYf9wEvkMjTYAOTeSsqq.gh) (12.3 KB)
