### 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
multi.instantiate();
				multi->add_transition(selected_transition_from, selected_transition_to, tr);
				for (int i = 0; i < transition_lines[closest].multi_transitions.size(); i++) {
					int index = transition_lines[closest].multi_transitions[i].transition_index;
					Ref<AnimationNodeStateMachineTransition> transition = state_machine->get_transition(index);
					StringName from = transition_lines[closest].multi_transitions[i].from_node;
					StringName to = transition_lines[closest].multi_transitions[i].to_node;
					multi->add_transition(from, to, transition);
				}
				EditorNode::get_singleton()->push_item(multi.ptr(), "", true);
			}
		}
		state_machine_draw->queue_redraw();
		_update_mode();
	}
	
	if (mb.is_valid() && dragging_selected_attempt && mb->get_button_index() == MouseButton::LEFT && !mb->is_pressed()) {
		if (dragging_selected) {
			Ref<AnimationNode> an = state_machine->get_node(selected_node);
			updating = true;
			EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
			undo_redo->create_action(TTR("Move Node"));
			for (int i = 0; i < node_rects.size(); i++) {
				if (!selected_nodes.has(node_rects[i].node_name)) {
					continue;
				}
				undo_redo->add_do_method(state_machine.ptr(), "set_node_position", node_rects[i].node_name, state_machine->get_node_position(node_rects[i].node_name) + drag_ofs / EDSCALE);
				undo_redo->add_undo_method(state_machine.ptr(), "set_node_position", node_rects[i].node_name, state_machine->get_node_position(node_rects[i].node_name));
			}
			undo_redo->add_do_method(this, "_update_graph");