isolate method
Isolates a new leaf node starting at index with specified length.
Splitting logic is identical to one described in splitAt, with one
exception that it is required for index to always be less than this
node's length. As a result this method always returns a LeafNode
instance. Note that returned node may still be the same as this node
if provided index is 0.
Implementation
LeafNode isolate(int index, int length) {
assert(
index >= 0 && index < this.length && (index + length <= this.length),
'Index or length is out of bounds. Index: $index, length: $length. '
'Actual node length: ${this.length}.');
// Since `index < this.length` (guarded by assert) below line
// always returns a new node.
final target = splitAt(index)!;
target.splitAt(length);
return target;
}