set method
A tree with toSet at relativePath.
Implementation
ImmutableTree<T> set(Path relativePath, T? toSet) {
if (relativePath.isEmpty) {
return ImmutableTree<T>._(toSet, children);
}
final ChildKey front = relativePath.front!;
final ImmutableTree<T> child = children[front] ?? ImmutableTree<T>.empty();
final ImmutableTree<T> newChild = child.set(relativePath.popFront(), toSet);
return ImmutableTree<T>._(value, children.insert(front, newChild));
}