### 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
void _create_remap_for_node(Node *p_node, HashMap<Ref<Resource>, Ref<Resource>> &r_remap);
	void _create_remap_for_resource(Ref<Resource> p_resource, HashMap<Ref<Resource>, Ref<Resource>> &r_remap);
	void _list_all_subresources(PopupMenu *p_menu);
	void _gather_resources(Node *p_node, List<Pair<Ref<Resource>, Node *>> &r_resources);
	void _edit_subresource(int p_idx, const PopupMenu *p_from_menu);
	bool profile_allow_editing = true;
	bool profile_allow_script_editing = true;
	static void _update_configuration_warning();
	bool _update_node_path(Node *p_root_node, NodePath &r_node_path, HashMap<Node *, NodePath> *p_renames) const;
	bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames) const;
private:
	static SceneTreeDock *singleton;
public:
	static SceneTreeDock *get_singleton() { return singleton; }
protected:
	void _notification(int p_what);
	static void _bind_methods();
public:
	String get_filter();
	void set_filter(const String &p_filter);
	void save_branch_to_file(String p_directory);
	void _focus_node();
	void add_root_node(Node *p_node);
	void set_edited_scene(Node *p_scene);
	void instantiate(const String &p_file);
	void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr);
	void set_selected(Node *p_node, bool p_emit_selected = false);
	void fill_path_renames(Node *p_node, Node *p_new_parent, HashMap<Node *, NodePath> *p_renames);
	void perform_node_renames(Node *p_base, HashMap<Node *, NodePath> *p_renames, HashMap<Ref<Animation>, HashSet<int>> *r_rem_anims = nullptr);
	SceneTreeEditor *get_tree_editor() { return scene_tree; }