### Godot version

4.2 Stable

### System information

Linux

### Issue description

Calling TreeItem set_text() on a TreeItem that was removed via remove_child() causes debugging to end and the application to close without any error message.

### Steps to reproduce

Run the included example to get the debugger to crash. Comment out "treeItem.remove_child(subTreeItem)" for normal behaviour. 

### Minimal reproduction project

[treeItemCrash.zip](https://github.com/godotengine/godot/files/13534005/treeItemCrash.zip)

ERR_FAIL_COND(p_event.is_null());
	Ref<InputEventKey> k = p_event;
	bool is_command = k.is_valid() && k->is_command_or_control_pressed();
	if (p_event->is_action("ui_right", true) && p_event->is_pressed()) {
		if (!cursor_can_exit_tree) {
			accept_event();
		}
		if (!selected_item || select_mode == SELECT_ROW || selected_col > (columns.size() - 1)) {
			return;
		}
		if (k.is_valid() && k->is_alt_pressed()) {
			selected_item->set_collapsed(false);
			TreeItem *next = selected_item->get_first_child();
			while (next && next != selected_item->next) {
				next->set_collapsed(false);
				next = next->get_next_visible();
			}
		} else {
			_go_right();
		}
	} else if (p_event->is_action("ui_left", true) && p_event->is_pressed()) {
		if (!cursor_can_exit_tree) {
			accept_event();
		}
		if (!selected_item || select_mode == SELECT_ROW || selected_col < 0) {
			return;
		}
		if (k.is_valid() && k->is_alt_pressed()) {
			selected_item->set_collapsed(true);