### Godot version

4.2 beta4

### System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 30.0.15.1403) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

### Issue description

When you select a node, the Node dock's signals and groups will point to that node. When you unselect it, the dock is properly cleared. If you instead delete the node, the dock content will stay and you can still make changes, which will go into the void (there is no way to restore the node without undoing the changes). What's worse, if you make a new scene and do the same to root node, it will result in editor crash.

Related is that the inspector does not fully clear either. The node header stays, the content is empty:
![image](https://github.com/godotengine/godot/assets/2223172/611930e6-f845-4473-827e-1aad087c01a3)


### Steps to reproduce

1. Add node
2. Select it
3. Go to Node dock's Groups
4. Press Delete to delete the node (tested with the "no confirm" action, IIRC Shift+Delete by default?)
5. The node is removed, but dock stays
6. Add groups

### Minimal reproduction project

N/A
connections->update_tree();
}
void NodeDock::set_node(Node *p_node) {
	connections->set_node(p_node);
	groups->set_current(p_node);
	if (p_node) {
		last_valid_node = p_node;
	}
	if (p_node) {
		if (connections_button->is_pressed()) {
			connections->show();
		} else {
			groups->show();
		}
		mode_hb->show();
		select_a_node->hide();
	} else {
		connections->hide();
		groups->hide();
		mode_hb->hide();
		select_a_node->show();
	}
}
void NodeDock::restore_last_valid_node() {