replaceById function
Replace node id with updated anywhere in the tree.
If id does not exist, returns doc unchanged.
Implementation
CanvasSceneDocument replaceById(
CanvasSceneDocument doc,
NodeId id,
Node updated,
) {
return rewriteSceneDocument(
doc,
(n) => rewritePostOrder(
n,
(m) => (m.id == id) ? updated : m,
prune: (m) => m.id == id,
),
);
}