How to remove children entities when a parent entity is removed

I have a lot of entities which share a single parent entity (through parent property), this allows me to hide and show them all at once (for example). I have multiple such parent entities

If I remove the parentEntity from the entity collection, the children still remains there. What I want is to remove them also.

Currently, before removing the desired parentEntity, I iterate over it’s _children array and remove each child one by one. I don’t like it

because ‘_children’ is private.

Can you suggest a correct approach?

The only correct solution right now is to iterate over all of the entities and remove them if their parent object matches the object you removed. We might expose _children as public in the future or make this use case easier in other ways, but for now that’s the only way.

Matt, yall still thinking about this one? :slight_smile:
_children is accessible but my TypeScript yells at me. I slapped it with a @ts-ignore for the time being but just wondering is this was something you guys were still looking to do?