### 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
top_hb->add_child(selection_tools_hb);
	selection_tools_hb->add_child(memnew(VSeparator));
	tool_group = memnew(Button);
	tool_group->set_flat(true);
	tool_group->set_tooltip_text(TTR("Group Selected Node(s)") + " (Ctrl+G)");
	tool_group->connect("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_group_selected_nodes));
	tool_group->set_disabled(true);
	selection_tools_hb->add_child(tool_group);
	tool_ungroup = memnew(Button);
	tool_ungroup->set_flat(true);
	tool_ungroup->set_tooltip_text(TTR("Ungroup Selected Node") + " (Ctrl+Shift+G)");
	tool_ungroup->connect("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_ungroup_selected_nodes));
	tool_ungroup->set_visible(false);
	selection_tools_hb->add_child(tool_ungroup);
	tool_erase = memnew(Button);
	tool_erase->set_flat(true);
	tool_erase->set_tooltip_text(TTR("Remove selected node or transition."));
	tool_erase->connect("pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_erase_selected).bind(false));
	tool_erase->set_disabled(true);
	selection_tools_hb->add_child(tool_erase);
	transition_tools_hb = memnew(HBoxContainer);
	top_hb->add_child(transition_tools_hb);
	transition_tools_hb->add_child(memnew(VSeparator));
	transition_tools_hb->add_child(memnew(Label(TTR("Transition:"))));
	switch_mode = memnew(OptionButton);
	transition_tools_hb->add_child(switch_mode);
	auto_advance = memnew(Button);
	auto_advance->set_flat(true);
	auto_advance->set_tooltip_text(TTR("New Transitions Should Auto Advance"));
	auto_advance->set_toggle_mode(true);