filter
Filters a CompositionNode
and its hierarchy based on the provided filter function. The method recursively applies the filter to the node and its children, creating a new hierarchy that contains only the nodes for which the filter returns true. If the filter condition fails for the root node, null is returned.
For GroupNode
instances, the method applies the filter to its children and creates a new GroupNode
containing filtered children that satisfy the filter condition. For ShapeNode
instances, a copy is created if the filter condition is met.
Return
A new filtered CompositionNode
tree, or null if the root node does not pass the filter.
Parameters
A lambda function that takes a CompositionNode
and returns a Boolean
. The function determines if a node should be included in the resulting hierarchy.