### 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
}
	
	if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && !mb->is_pressed() && box_selecting) {
		box_selecting = false;
		state_machine_draw->queue_redraw();
		_update_mode();
	}
	Ref<InputEventMouseMotion> mm = p_event;
	
	if (mm.is_valid() && mm->get_button_mask().has_flag(MouseButtonMask::MIDDLE)) {
		h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
		v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
	}
	
	if (mm.is_valid() && connecting && connection_follows_cursor && !read_only) {
		connecting_to = mm->get_position();
		connecting_to_node = StringName();
		state_machine_draw->queue_redraw();
		for (int i = node_rects.size() - 1; i >= 0; i--) { 
			if (node_rects[i].node_name != connecting_from && node_rects[i].node.has_point(connecting_to)) { 
				connecting_to_node = node_rects[i].node_name;
				return;
			}
		}
	}
	
	if (mm.is_valid() && dragging_selected_attempt && !read_only) {
		dragging_selected = true;
		drag_ofs = mm->get_position() - drag_from;
		snap_x = StringName();