### Godot version

v4.1.beta.custom_build [dbd482faa]

### System information

macOS 13.3.0 - Vulkan (Forward+) - integrated Apple M1 Pro - Apple M1 Pro (8 Threads)

### Issue description

Some editor action like changing type will replace the node by another node. Right now Node properties will still point to the old Node. 

### Steps to reproduce

1. create a scene with a root node 
2. attach a script that exports a node property
3. set the property to point to the root node 
4. change the type of the root node
5. look at the property it will error out and the editor will be blank

### Minimal reproduction project

[Test.zip](https://github.com/godotengine/godot/files/11764206/Test.zip)
with MRP you can start at step 4
outline_lines.resize(lines.size());
		computed_outline_lines.resize(lines.size());
		for (int pi = 0; pi < lines.size(); pi++) {
			Vector<Vector2> ol;
			Vector<Vector2> col;
			ol.resize(lines[pi].size());
			col.resize(lines[pi].size());
			for (int i = 0; i < lines[pi].size(); i++) {
				Vector2 vtx = lines[pi][i];
				ol.write[i] = vtx;
				vtx -= rect.position; 
				
				if (node->is_flipped_h()) {
					vtx.x = rect.size.x - vtx.x - 1.0;
				}
				if (node->is_flipped_v()) {
					vtx.y = rect.size.y - vtx.y - 1.0;
				}
				if (node->is_centered()) {
					vtx -= rect.size / 2.0;
				}
				col.write[i] = vtx;
			}
			outline_lines.write[pi] = ol;
			computed_outline_lines.write[pi] = col;
		}
	}
	debug_uv->queue_redraw();
}
void Sprite2DEditor::_create_node() {