### Godot version

v4.1.beta.custom_build [f23a12007]

### System information

macOS 13.3.0 - Vulkan (Forward+) - integrated Apple M1 Pro - Apple M1 Pro (8 Threads)

### Issue description

This was discovered through inspection of https://github.com/godotengine/godot/issues/78578#issuecomment-1603236210. This is happening when focus is requested by one node that ask for the previous focused node to release focus. But during focus release it remove the new focused node from the scene tree. This means the new focused node will first exit scene tree and then be focused. This means it will not be unfocused because release focus happens during exit of the tree. 

### Steps to reproduce

1. run the MRP
2. click on one of the LineEdit
3. click on the other one 
4. See Godot Crash

### Minimal reproduction project

[Test.zip](https://github.com/godotengine/godot/files/11841284/Test.zip)


ERR_MAIN_THREAD_GUARD;
	if (world_2d == p_world_2d) {
		return;
	}
	if (is_inside_tree()) {
		RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
	}
	if (world_2d.is_valid()) {
		world_2d->remove_viewport(this);
	}
	if (p_world_2d.is_valid()) {
		bool do_propagate = world_2d.is_valid() && is_inside_tree();
		world_2d = p_world_2d;
		if (do_propagate) {
			_propagate_world_2d_changed(this);
		}
	} else {
		WARN_PRINT("Invalid world_2d");
		world_2d = Ref<World2D>(memnew(World2D));
	}
	world_2d->register_viewport(this);
	_update_audio_listener_2d();
	if (is_inside_tree()) {
		current_canvas = find_world_2d()->get_canvas();
		RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
	}
}
Ref<World2D> Viewport::find_world_2d() const {