### Godot version

41e5f5b0930343ef548a56d553ba20fafd672147

### System information

Windows 10, Vulkan, Intel® Core™ i7-8700K, Nvidia GTX 1080 (471.11)

### Issue description

The editor will crash if you select an AnimationTree node then select another node. This seems to be caused by the edit function assigning a null object via the edit interface, then calling another function which does not appear to be null.

### Steps to reproduce

Create an AnimationTree node then select another node.

### Minimal reproduction project

N/A
}
				Vector2 node_position = group_sm->get_node_position(nodes[i].name);
				NodeUR new_node;
				new_node.name = nodes[i].name;
				new_node.position = node_position;
				new_node.node = nodes[i].node;
				nodes_ur.push_back(new_node);
			}
			for (int i = 0; i < group_sm->get_transition_count(); i++) {
				String from = group_sm->get_transition_from(i);
				String to = group_sm->get_transition_to(i);
				Ref<AnimationNodeStateMachineTransition> tr = group_sm->get_transition(i);
				TransitionUR new_tr;
				new_tr.new_from = from.replace_first("../", "");
				new_tr.new_to = to.replace_first("../", "");
				new_tr.old_from = from;
				new_tr.old_to = to;
				new_tr.transition = tr;
				transitions_ur.push_back(new_tr);
			}
			for (int i = 0; i < nodes_ur.size(); i++) {
				undo_redo->add_do_method(group_sm.ptr(), "remove_node", nodes_ur[i].name);
				undo_redo->add_undo_method(state_machine.ptr(), "remove_node", nodes_ur[i].name);
			}
			undo_redo->add_do_method(state_machine.ptr(), "remove_node", group_name);
			undo_redo->add_undo_method(state_machine.ptr(), "add_node", group_name, group_sm, group_position);
			for (int i = 0; i < nodes_ur.size(); i++) {
				new_selected_nodes.insert(nodes_ur[i].name);
				undo_redo->add_do_method(state_machine.ptr(), "add_node", nodes_ur[i].name, nodes_ur[i].node, nodes_ur[i].position);
				undo_redo->add_undo_method(group_sm.ptr(), "add_node", nodes_ur[i].name, nodes_ur[i].node, nodes_ur[i].position);