### 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 (current_node != StringName() && state_machine->has_node(current_node)) {
					String next = current_node;
					Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next);
					Ref<AnimationNodeStateMachinePlayback> current_node_playback;
					while (anodesm.is_valid()) {
						current_node_playback = tree->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback");
						next += "/" + current_node_playback->get_current_node();
						anodesm = anodesm->get_node(current_node_playback->get_current_node());
					}
					
					if (current_node_playback.is_valid()) {
						current_play_pos = current_node_playback->get_current_play_pos();
						current_length = current_node_playback->get_current_length();
					}
				}
			}
			if (last_play_pos != current_play_pos || fade_from_last_play_pos != fade_from_current_play_pos) {
				last_play_pos = current_play_pos;
				fade_from_last_play_pos = fade_from_current_play_pos;
				state_machine_play_pos->queue_redraw();
			}
		} break;
		case NOTIFICATION_VISIBILITY_CHANGED: {
			over_node = StringName();
			set_process(is_visible_in_tree());
		} break;
	}
}
void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) {