### Godot version

v4.0.3.stable.official [5222a99f5]

### System information

Godot v4.0.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 (NVIDIA; 31.0.15.1694) - Intel(R) Core(TM) i5-10600KF CPU @ 4.10GHz (12 Threads)

### Issue description
Freeing a node after freeing its owner sometimes inconsistently causes a crash, and other times throws the following error:
```
erase: Condition "p_I->data != this" is true. Returning: false
  <C++ Source>   ./core/templates/list.h:223 @ erase()
```
Old description:
<details>
Calling `queue_free()` in certain conditions cause the following error to be thrown, and occasionally cause errorless crashes.
<br><code>
erase: Condition "p_I->data != this" is true. Returning: false
  <C++ Source>   ./core/templates/list.h:223 @ erase()
</code><br>
The exact conditions aren't clear: commenting out almost any line or awaiting a frame almost anywhere prevents the error, so maybe some there's some race condition?
<br><br>
The error also isn't super consistent, but I've managed to create a minimal reproduction project that causes the error more >50% of the time.</details>

**Call stack on crash:**
```
================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.0.3.stable.custom_build (5222a99f5d38cd5346254cefed8f65315bca4fcb)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] List<Node *,DefaultAllocator>::_Data::erase (C:\Users\Hayden\Documents\Godot\Source\godot\core\templates\list.h:238)
[1] List<Node *,DefaultAllocator>::_Data::erase (C:\Users\Hayden\Documents\Godot\Source\godot\core\templates\list.h:238)
[2] List<Node *,DefaultAllocator>::erase (C:\Users\Hayden\Documents\Godot\Source\godot\core\templates\list.h:429)
[3] Node::_propagate_after_exit_tree (C:\Users\Hayden\Documents\Godot\Source\godot\scene\main\node.cpp:265)
[4] Node::remove_child (C:\Users\Hayden\Documents\Godot\Source\godot\scene\main\node.cpp:1227)
[5] Node::_notification (C:\Users\Hayden\Documents\Godot\Source\godot\scene\main\node.cpp:168)
[6] Node::_notificationv (C:\Users\Hayden\Documents\Godot\Source\godot\scene\main\node.h:46)
[7] Object::notification (C:\Users\Hayden\Documents\Godot\Source\godot\core\object\object.cpp:792)
[8] Object::_predelete (C:\Users\Hayden\Documents\Godot\Source\godot\core\object\object.cpp:197)
[9] predelete_handler (C:\Users\Hayden\Documents\Godot\Source\godot\core\object\object.cpp:1826)
[10] memdelete<Object> (C:\Users\Hayden\Documents\Godot\Source\godot\core\os\memory.h:105)
[11] SceneTree::_flush_delete_queue (C:\Users\Hayden\Documents\Godot\Source\godot\scene\main\scene_tree.cpp:1065)
[12] SceneTree::process (C:\Users\Hayden\Documents\Godot\Source\godot\scene\main\scene_tree.cpp:476)
[13] Main::iteration (C:\Users\Hayden\Documents\Godot\Source\godot\main\main.cpp:3169)
[14] OS_Windows::run (C:\Users\Hayden\Documents\Godot\Source\godot\platform\windows\os_windows.cpp:1295)
[15] widechar_main (C:\Users\Hayden\Documents\Godot\Source\godot\platform\windows\godot_windows.cpp:181)
[16] _main (C:\Users\Hayden\Documents\Godot\Source\godot\platform\windows\godot_windows.cpp:203)
[17] main (C:\Users\Hayden\Documents\Godot\Source\godot\platform\windows\godot_windows.cpp:217)
[18] WinMain (C:\Users\Hayden\Documents\Godot\Source\godot\platform\windows\godot_windows.cpp:231)
[19] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[20] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================
```

### Steps to reproduce
EDIT: Made a simpler single script MRP:
```gdscript
extends Node

func _process(delta: float) -> void:
	var owner_node = Node.new()
	var child_node = Node.new()
	
	owner_node.add_child(child_node)
	child_node.owner = owner_node
	child_node.reparent(self)
	
	owner_node.queue_free()
	await get_tree().process_frame
	child_node.queue_free()
```

Old method:
Simply run the provided MRP. The error doesn't show up every time it is run, nor does it cause a crash everytime, so you may need to run it more than once.

While most of my testing was done in 4.0.3, this still occurs in 4.1 beta 3 as well

### Minimal reproduction project

[MRP.zip](https://github.com/godotengine/godot/files/11878491/MRP.zip)
return data.unique_name_in_owner;
}
void Node::set_owner(Node *p_owner) {
	ERR_MAIN_THREAD_GUARD
	if (data.owner) {
		_clean_up_owner();
	}
	ERR_FAIL_COND(p_owner == this);
	if (!p_owner) {
		return;
	}
	Node *check = this->get_parent();
	bool owner_valid = false;
	while (check) {
		if (check == p_owner) {
			owner_valid = true;
			break;
		}
		check = check->data.parent;
	}
	ERR_FAIL_COND_MSG(!owner_valid, "Invalid owner. Owner must be an ancestor in the tree.");
	_set_owner_nocheck(p_owner);
	if (data.unique_name_in_owner) {
		_acquire_unique_name_in_owner();
	}
}
Node *Node::get_owner() const {