Folds the tree bottom-up: fn gets each node's path, value and its children's results.
fn
V fold<V>(V Function(Path path, T? value, Map<ChildKey, V> children) fn) => _fold(Path.empty, fn);