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

if (_scroll(false, mb->get_factor() / 8)) {
					accept_event();
				}
			} break;
			case MouseButton::WHEEL_LEFT: {
				if (_scroll(true, -mb->get_factor() / 8)) {
					accept_event();
				}
			} break;
			case MouseButton::WHEEL_RIGHT: {
				if (_scroll(true, mb->get_factor() / 8)) {
					accept_event();
				}
			} break;
			default:
				break;
		}
	}
	Ref<InputEventPanGesture> pan_gesture = p_event;
	if (pan_gesture.is_valid()) {
		double prev_v = v_scroll->get_value();
		v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
		double prev_h = h_scroll->get_value();
		if (is_layout_rtl()) {
			h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * -pan_gesture->get_delta().x / 8);
		} else {
			h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
		}
		if (v_scroll->get_value() != prev_v || h_scroll->get_value() != prev_h) {
			accept_event();