A hierarchical tree: every node carries a payload and an array of child branches, each itself a tree. It is immutable — the With… and branch operations return new nodes — and it is the same shape the UI layer uses for nested content.
Functions
Collection.Tree.AppendBranch
A copy of the node with one branch added to the end.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The starting node. branchCollection.Tree(PayloadType)The child node to add.
Returns Returns Collection.Tree(PayloadType) — a new node with the extra branch.
Example LET Collection.Tree ( Text ) grown = Collection.Tree.AppendBranch root leaf Adds a child to the end of the branch list, returning a new node.
Collection.Tree.BranchAtOptional
The branch at an index, absent when the index is out of range.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The node to read. indexMaths.IntegerThe branch position to read.
Returns Returns Collection.Optional(Collection.Tree(PayloadType)) — present with the child branch, or absent when out of range.
Example LET Collection.Optional ( Collection.Tree ( Text ) ) firstChild = Collection.Tree.BranchAtOptional root 0 Absent when the node has no branch at that index.
Collection.Tree.BranchCount
The number of direct branches on the node.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The node to measure.
Returns Returns Maths.Integer — the count of direct child branches.
Example LET Maths.Integer children = Collection.Tree.BranchCount root Counts only direct children, not the whole subtree.
Collection.Tree.EachBranch
Runs a block once for each direct branch.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The node whose branches to iterate.
Holes Name Returns Description branchCallbacknothingRun once per direct branch, each in its own reactive branch scope.Inputs Name Type Description branchCollection.Tree(PayloadType)The current child node.
Example Collection.Tree.EachBranch root
INPUT Collection.Tree ( Text ) branch
Ui.Content.Text branch . payload Walks the direct children; recurse by calling EachBranch again inside the block.
Collection.Tree.HasBranches
Yields yes when the node has at least one branch.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The node to test.
Returns Returns Logic.Maybe — yes when the node has one or more branches — the negation of IsLeaf.
Example LET Logic.Maybe hasKids = Collection.Tree.HasBranches root The opposite of IsLeaf.
Collection.Tree.IsLeaf
Yields yes when the node has no branches.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The node to test.
Returns Returns Logic.Maybe — yes when the node has no branches, otherwise no.
Example LET Logic.Maybe leaf = Collection.Tree.IsLeaf root A leaf is a node with an empty branch list.
Collection.Tree.RemoveBranch
A copy of the node with the branch at an index removed.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The starting node. indexMaths.IntegerThe branch position to remove.
Returns Returns Collection.Tree(PayloadType) — a new node with that branch dropped.
Example LET Collection.Tree ( Text ) pruned = Collection.Tree.RemoveBranch root 0 Drops the first branch and returns the trimmed node.
Collection.Tree.WithBranches
A copy of the node with a different set of branches, payload unchanged.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The starting node. branchesCollection.Array(Collection.Tree(PayloadType))The branches for the new node.
Returns Returns Collection.Tree(PayloadType) — a new node with the given branches and the same payload.
Example LET Collection.Tree ( Text ) regrown = Collection.Tree.WithBranches root kids Replaces the whole branch list, keeping the payload.
Collection.Tree.WithPayload
A copy of the node with a different payload, branches unchanged.
Generics Name Description PayloadTypeThe node's payload type.
Parameters Name Type Description treeCollection.Tree(PayloadType)The starting node. payloadPayloadTypeThe payload for the new node.
Returns Returns Collection.Tree(PayloadType) — a new node with the given payload and the same branches.
Example LET Collection.Tree ( Text ) renamed = Collection.Tree.WithPayload root "top" Trees are immutable, so this returns a fresh node with the payload replaced.