flatten method
Flattens the structure with the given depth
so that only the returned node is actually a root node.
When the depth
is 1
, then only the direct children are allowed, if it has higher, there can be additional
descendents. depth
must not be lower than 1
. depth
defaults to 2
.
Implementation
SequenceNode flatten({int depth = 2}) {
assert(depth >= 1, 'depth must be at least 1 ($depth is invalid)');
final root = SequenceNode.root(isUid);
_flatten(depth, root);
return root;
}