I was able to get the desired output by replacing
this.dataSource.data.slice();
with
JSON.parse(JSON.stringify(this.dataSource.data));
,
which performs a deep copy.
I also changed the HTML from:
<div role="group">
<ng-container matTreeNodeOutlet></ng-container>
</div>
to:
<div role="group" *ngIf="treeControl.isExpanded(node)">
<ng-container matTreeNodeOutlet></ng-container>
</div>
to conditionally render the child nodes only when the current node is expanded.
If the problem still isn't solved, you can check this StackOverflow link for help: