### 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 _nodes_drag_begin();
	virtual void input(const Ref<InputEvent> &p_event) override;
	virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
	void _new_scene_from(String p_file);
	void _set_node_owner_recursive(Node *p_node, Node *p_owner);
	bool _validate_no_foreign();
	bool _validate_no_instance();
	void _selection_changed();
	void _update_script_button();
	void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, HashMap<Node *, NodePath> *p_renames);
	bool _has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delete) const;
	void _normalize_drop(Node *&to_node, int &to_pos, int p_type);
	void _nodes_dragged(Array p_nodes, NodePath p_to, int p_type);
	void _files_dropped(Vector<String> p_files, NodePath p_to, int p_type);
	void _script_dropped(String p_file, NodePath p_to);
	void _quick_open();
	void _tree_rmb(const Vector2 &p_menu_pos);
	void _update_tree_menu();
	void _filter_changed(const String &p_filter);
	void _filter_gui_input(const Ref<InputEvent> &p_event);
	void _filter_option_selected(int option);
	void _append_filter_options_to(PopupMenu *p_menu, bool p_include_separator = true);
	void _perform_instantiate_scenes(const Vector<String> &p_files, Node *parent, int p_pos);
	void _replace_with_branch_scene(const String &p_file, Node *base);
	void _remote_tree_selected();
	void _local_tree_selected();
	void _update_create_root_dialog();
	void _favorite_root_selected(const String &p_class);
	void _feature_profile_changed();
	void _clear_clipboard();