Parenting entities makes _children[] of parent dirty

There are a few threads revolving around this topic (example, maybe another), but one overarching question is what exactly you are trying to accomplish.

One could argue (and should think) quite a bit about which behavior could cause the “least astonishment” here. Imagine that the child was automatically removed from the parent when it is removed from the viewer. We’d almost certainly see threads and issues being opened with the question “Why is my child removed from the parent when I remove the child from the viewer?” :slightly_smiling_face:

However, the parent setter of an entity already does the maintenance work of removing the child from the former parent. So in your case, one solution might be to explicitly call
childEntity.parent = undefined; // Detach child from parent
after removing the child from the viewer.

One has to be very clear about the intentions here, and make sure that this does not break any expectations that other parts of the code may have. But just for illustration, here’s a Sandcastle of that: