### Godot version

v4.1.1-stable_mono_win64

### System information

Windows 11

### Issue description

I removed the node to replace it with another, but when I change the path in the code, the engine crashes for me.

### Steps to reproduce

I did a screen recording as it happens:

https://github.com/godotengine/godot/assets/116289408/b2fd2689-8d82-44e8-8e02-be01674842e1



### Minimal reproduction project

[MixApo.zip](https://github.com/godotengine/godot/files/12208403/MixApo.zip)

code_completion_force_item_center = -1;
			queue_redraw();
			accept_event();
			return;
		}
		if (k->is_action("ui_end", true)) {
			code_completion_current_selected = code_completion_options.size() - 1;
			code_completion_force_item_center = -1;
			queue_redraw();
			accept_event();
			return;
		}
		if (k->is_action("ui_text_completion_replace", true) || k->is_action("ui_text_completion_accept", true)) {
			confirm_code_completion(k->is_action("ui_text_completion_replace", true));
			accept_event();
			return;
		}
		if (k->is_action("ui_cancel", true)) {
			cancel_code_completion();
			accept_event();
			return;
		}
		if (k->is_action("ui_text_backspace", true)) {
			backspace();
			_filter_code_completion_candidates_impl();
			accept_event();
			return;
		}
		if (k->is_action("ui_left", true) || k->is_action("ui_right", true)) {
			update_code_completion = true;