### 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
AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
	if (!tree) {
		return;
	}
	menu->clear();
	animations_menu->clear();
	animations_to_add.clear();
	List<StringName> classes;
	classes.sort_custom<StringName::AlphCompare>();
	ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
	menu->add_submenu_item(TTR("Add Animation"), "animations");
	if (tree->has_node(tree->get_animation_player())) {
		AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(tree->get_node(tree->get_animation_player()));