### 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
connecting_to_node = nodes_to_connect[p_index];
	_add_transition();
}
void AnimationNodeStateMachineEditor::_add_transition(const bool p_nested_action) {
	if (connecting_from != StringName() && connecting_to_node != StringName()) {
		if (state_machine->has_transition(connecting_from, connecting_to_node)) {
			EditorNode::get_singleton()->show_warning("Transition exists!");
			connecting = false;
			return;
		}
		Ref<AnimationNodeStateMachineTransition> tr;
		tr.instantiate();
		tr->set_advance_mode(auto_advance->is_pressed() ? AnimationNodeStateMachineTransition::AdvanceMode::ADVANCE_MODE_AUTO : AnimationNodeStateMachineTransition::AdvanceMode::ADVANCE_MODE_ENABLED);
		tr->set_switch_mode(AnimationNodeStateMachineTransition::SwitchMode(switch_mode->get_selected()));
		EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
		if (!p_nested_action) {
			updating = true;
			undo_redo->create_action(TTR("Add Transition"));
		}
		undo_redo->add_do_method(state_machine.ptr(), "add_transition", connecting_from, connecting_to_node, tr);
		undo_redo->add_undo_method(state_machine.ptr(), "remove_transition", connecting_from, connecting_to_node);
		undo_redo->add_do_method(this, "_update_graph");
		undo_redo->add_undo_method(this, "_update_graph");
		if (!p_nested_action) {
			undo_redo->commit_action();
			updating = false;
		}
		selected_transition_from = connecting_from;
		selected_transition_to = connecting_to_node;
		selected_transition_index = transition_lines.size();