deepCopy method
A deep copy, leaving out repeat templates unless includeTemplates.
Implementation
TreeElement deepCopy({required bool includeTemplates}) {
final copy = shallowCopy().._children.clear();
for (final child in _children) {
if (includeTemplates ||
child.multiplicity != TreeReference.indexTemplate) {
copy.addChild(child.deepCopy(includeTemplates: includeTemplates));
}
}
return copy;
}