### 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
continue;
			}
			Ref<AnimationNode> node = state_machine->get_node(E);
			Vector2 node_position = state_machine->get_node_position(E);
			group_position += node_position;
			NodeUR new_node;
			new_node.name = E;
			new_node.node = node;
			new_node.position = node_position;
			nodes_ur.push_back(new_node);
		}
		
		for (int i = 0; i < state_machine->get_transition_count(); i++) {
			String from = state_machine->get_transition_from(i);
			String to = state_machine->get_transition_to(i);
			String local_from = from.get_slicec('/', 0);
			String local_to = to.get_slicec('/', 0);
			String old_from = from;
			String old_to = to;
			bool from_selected = false;
			bool to_selected = false;
			if (selected_nodes.has(local_from) && local_from != state_machine->start_node) {
				from_selected = true;
			}
			if (selected_nodes.has(local_to) && local_to != state_machine->end_node) {
				to_selected = true;
			}
			if (!from_selected && !to_selected) {
				continue;
			}