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

item_rect.position.x = get_size().width - item_rect.position.x - item_rect.size.x;
			}
			Point2i text_pos = item_rect.position;
			text_pos.y += Math::floor(p_draw_ofs.y) - _get_title_button_height();
			switch (p_item->cells[i].mode) {
				case TreeItem::CELL_MODE_STRING: {
					draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color);
				} break;
				case TreeItem::CELL_MODE_CHECK: {
					Ref<Texture2D> checked = theme_cache.checked;
					Ref<Texture2D> unchecked = theme_cache.unchecked;
					Ref<Texture2D> indeterminate = theme_cache.indeterminate;
					Point2i check_ofs = item_rect.position;
					check_ofs.y += Math::floor((real_t)(item_rect.size.y - checked->get_height()) / 2);
					if (p_item->cells[i].indeterminate) {
						indeterminate->draw(ci, check_ofs);
					} else if (p_item->cells[i].checked) {
						checked->draw(ci, check_ofs);
					} else {
						unchecked->draw(ci, check_ofs);
					}
					int check_w = checked->get_width() + theme_cache.h_separation;
					text_pos.x += check_w;
					item_rect.size.x -= check_w;
					item_rect.position.x += check_w;
					draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color);
				} break;
				case TreeItem::CELL_MODE_RANGE: {
					if (!p_item->cells[i].text.is_empty()) {
						if (!p_item->cells[i].editable) {