apply method
node with every write applied, as the server applies one update (production check 39,
Q1, Q6, Q10 and F1 to F9, both key orders): pass 1 writes every value, at any depth (a node
whose last child goes keeps its priority as an emptied node); pass 2 writes every priority,
parents before children, each landing only on a node that then has a value or holds
hidden state (ChildrenNode.takesPriority); a null priority removes a kept one.
Implementation
Node apply(Node node) {
Node result = node;
for (final MapEntry<Path, Node> write in writesInServerOrder(this)) {
final ChildKey? back = write.key.back;
if (back != null &&
back.isPriorityKey &&
!ChildrenNode.takesPriority(result.getChild(write.key.parent!))) {
continue;
}
result = result.updateChild(write.key, write.value);
}
return result;
}