### 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->is_pressed() && !box_selecting && !connecting && ((tool_select->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) || (tool_create->is_pressed() && mb->get_button_index() == MouseButton::LEFT))) {
			connecting_from = StringName();
			_open_menu(mb->get_position());
		}
	}
	
	if (mb.is_valid() && !mb->is_shift_pressed() && !mb->is_ctrl_pressed() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
		selected_transition_from = StringName();
		selected_transition_to = StringName();
		selected_transition_index = -1;
		selected_multi_transition = TransitionLine();
		selected_node = StringName();
		for (int i = node_rects.size() - 1; i >= 0; i--) { 
			if (node_rects[i].play.has_point(mb->get_position())) { 
				if (play_mode->get_selected() == 1 || !playback->is_playing()) {
					
					playback->start(node_rects[i].node_name);
				} else {
					
					playback->travel(node_rects[i].node_name);
				}
				state_machine_draw->queue_redraw();
				return;
			}
			if (!read_only) {
				if (node_rects[i].name.has_point(mb->get_position()) && state_machine->can_edit_node(node_rects[i].node_name)) { 
					Ref<StyleBox> line_sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"));
					Rect2 edit_rect = node_rects[i].name;
					edit_rect.position -= line_sb->get_offset();
					edit_rect.size += line_sb->get_minimum_size();