### 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
undo_redo->add_do_method(this, "_update_graph");
		undo_redo->add_undo_method(this, "_update_graph");
		undo_redo->commit_action();
		if (!p_nested_action) {
			updating = false;
		}
		selected_nodes.clear();
	}
	if (!selected_multi_transition.multi_transitions.is_empty()) {
		delete_tree->clear();
		TreeItem *root = delete_tree->create_item();
		TreeItem *item = delete_tree->create_item(root);
		item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
		item->set_text(0, String(selected_transition_from) + " -> " + selected_transition_to);
		item->set_editable(0, true);
		for (int i = 0; i < selected_multi_transition.multi_transitions.size(); i++) {
			String from = selected_multi_transition.multi_transitions[i].from_node;
			String to = selected_multi_transition.multi_transitions[i].to_node;
			item = delete_tree->create_item(root);
			item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
			item->set_text(0, from + " -> " + to);
			item->set_editable(0, true);
		}
		delete_window->popup_centered(Vector2(400, 200));
		return;
	}
	if (selected_transition_to != StringName() && selected_transition_from != StringName() && state_machine->has_transition(selected_transition_from, selected_transition_to)) {
		Ref<AnimationNodeStateMachineTransition> tr = state_machine->get_transition(state_machine->find_transition(selected_transition_from, selected_transition_to));
		if (!p_nested_action) {
			updating = true;