### 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 (cache.click_type == Cache::CLICK_BUTTON && cache.click_item == p_item && cache.click_column == i && cache.click_index == j && !p_item->cells[i].buttons[j].disabled) {
					
					Point2 od = button_ofs;
					if (rtl) {
						od.x = get_size().width - od.x - button_size.x;
					}
					theme_cache.button_pressed->draw(get_canvas_item(), Rect2(od.x, od.y, button_size.width, MAX(button_size.height, label_h)));
				}
				button_ofs.y += (label_h - button_size.height) / 2;
				button_ofs += theme_cache.button_pressed->get_offset();
				if (rtl) {
					button_ofs.x = get_size().width - button_ofs.x - button_texture->get_width();
				}
				p_item->cells.write[i].buttons.write[j].rect = Rect2i(button_ofs, button_size);
				button_texture->draw(ci, button_ofs, p_item->cells[i].buttons[j].disabled ? Color(1, 1, 1, 0.5) : p_item->cells[i].buttons[j].color);
				item_width_with_buttons -= button_size.width + theme_cache.button_margin;
			}
			if (i == 0) {
				ofs = get_column_width(0);
			} else {
				ofs += item_width + buttons_width;
			}
			if (select_mode == SELECT_MULTI && selected_item == p_item && selected_col == i) {
				if (is_layout_rtl()) {
					cell_rect.position.x = get_size().width - cell_rect.position.x - cell_rect.size.x;
				}
				if (has_focus()) {
					theme_cache.cursor->draw(ci, cell_rect);
				} else {
					theme_cache.cursor_unfocus->draw(ci, cell_rect);