Otherwise we can have a segmentation fault if we try to call `add_child` on an already freed node. Fixes #35323.