How do I get all the entities under another one

if I do children, it just shows the first level. How do I get ALL the children?

  const allEntities: Entity[] = [];

  const collectEntitiesRecursively = (entity: Entity) => {
    allEntities.push(entity);
    for (const child of entity.children.values()) {
      collectEntitiesRecursively(child);
    }
  };

  for (const entity of game.world.children.values()) {
    collectEntitiesRecursively(entity);
  }

You can do it like this. For example, to get every entity under game.world you do the above. Replace that with local or any entity.