Entities have a pointer to their parent entity. If the parent entity is freed first, then freeing the child will cause access to the already freed parent.
This is fixed by adding a child pointer and clearing the child and parent pointers when either child or parent is freed.
Purely automatic change. In case of conflict with this change, apply the
other change and rerun the formatting to restore it:
$ python scripts/fix_style.py