### 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)

for (int i = 0; i < auto_brace_completion_pairs.size(); i++) {
		if (auto_brace_completion_pairs[i].open_key == p_open_key) {
			return auto_brace_completion_pairs[i].close_key;
		}
	}
	return String();
}
void CodeEdit::_update_draw_main_gutter() {
	set_gutter_draw(main_gutter, draw_breakpoints || draw_bookmarks || draw_executing_lines);
}
void CodeEdit::set_draw_breakpoints_gutter(bool p_draw) {
	draw_breakpoints = p_draw;
	set_gutter_clickable(main_gutter, p_draw);
	_update_draw_main_gutter();
}
bool CodeEdit::is_drawing_breakpoints_gutter() const {
	return draw_breakpoints;
}
void CodeEdit::set_draw_bookmarks_gutter(bool p_draw) {
	draw_bookmarks = p_draw;
	_update_draw_main_gutter();
}
bool CodeEdit::is_drawing_bookmarks_gutter() const {
	return draw_bookmarks;
}
void CodeEdit::set_draw_executing_lines_gutter(bool p_draw) {
	draw_executing_lines = p_draw;
	_update_draw_main_gutter();
}
bool CodeEdit::is_drawing_executing_lines_gutter() const {