### 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
EditorNode::get_singleton()->show_warning(TTR("Transition exists!"));
				connecting = false;
			} else {
				if (anodesm.is_valid() || end_node.is_valid()) {
					_open_connect_menu(mb->get_position());
				} else {
					_add_transition();
				}
			}
		} else {
			_open_menu(mb->get_position());
		}
		connecting_to_node = StringName();
		connection_follows_cursor = false;
		state_machine_draw->queue_redraw();
	}
	
	if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && tool_select->is_pressed()) {
		box_selecting = true;
		box_selecting_from = box_selecting_to = state_machine_draw->get_local_mouse_position();
		box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
				MIN(box_selecting_from.y, box_selecting_to.y),
				ABS(box_selecting_from.x - box_selecting_to.x),
				ABS(box_selecting_from.y - box_selecting_to.y));
		if (mb->is_ctrl_pressed() || mb->is_shift_pressed()) {
			previous_selected = selected_nodes;
		} else {
			selected_nodes.clear();
			previous_selected.clear();
		}