pub fn replace_node_in_tree( root: &Node, target: &NodeId, replacement: &Node, ) -> Option<Node>
Replace a node by ID in a tree, returning a new tree with the replacement. Returns None if the target was not found.