### 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 (r_to == p_from) {
		return;
	}
	
	Vector2 n = (r_to - p_from).normalized();
	while (p_rect.has_point(r_to)) {
		r_to -= n;
	}
}
void AnimationNodeStateMachineEditor::_state_machine_draw() {
	AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
	if (!tree) {
		return;
	}
	Ref<AnimationNodeStateMachinePlayback> playback = tree->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
	Ref<StyleBoxFlat> style = get_theme_stylebox(SNAME("state_machine_frame"), SNAME("GraphNode"));
	Ref<StyleBoxFlat> style_selected = get_theme_stylebox(SNAME("state_machine_selected_frame"), SNAME("GraphNode"));
	Ref<Font> font = get_theme_font(SNAME("title_font"), SNAME("GraphNode"));
	int font_size = get_theme_font_size(SNAME("title_font_size"), SNAME("GraphNode"));
	Color font_color = get_theme_color(SNAME("title_color"), SNAME("GraphNode"));
	Ref<Texture2D> play = get_theme_icon(SNAME("Play"), SNAME("EditorIcons"));
	Ref<Texture2D> edit = get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"));
	Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
	Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label"));
	linecolor.a *= 0.3;
	Ref<StyleBox> playing_overlay = get_theme_stylebox(SNAME("position"), SNAME("GraphNode"));
	Ref<StyleBoxFlat> start_overlay = style->duplicate();
	start_overlay->set_border_width_all(1 * EDSCALE);
	start_overlay->set_border_color(Color::html("#80f6cf"));
	Ref<StyleBoxFlat> end_overlay = style->duplicate();