Represents a node in a tree structure, capable of holding a value and a list of child nodes.
The type of the value stored in the TreeNode.
A list of child TreeNodes, defaulting to an empty list.
The value contained in the TreeNode.
Filters the tree based on a given predicate.
Flattens the tree into a sequence of pairs containing each node's value and its depth.
Returns a string representation of the TreeNode.