### 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
}
	}
	
	for (const StringName &E : nodes) {
		Ref<AnimationNode> anode = state_machine->get_node(E);
		String name = E;
		bool needs_editor = AnimationTreeEditor::get_singleton()->can_edit(anode);
		Ref<StyleBox> sb = selected_nodes.has(E) ? style_selected : style;
		Size2 s = sb->get_minimum_size();
		int strsize = font->get_string_size(name, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;
		s.width += strsize;
		s.height += MAX(font->get_height(font_size), play->get_height());
		s.width += sep + play->get_width();
		if (needs_editor) {
			s.width += sep + edit->get_width();
		}
		Vector2 offset;
		offset += state_machine->get_node_position(E) * EDSCALE;
		if (selected_nodes.has(E) && dragging_selected) {
			offset += drag_ofs;
		}
		offset -= s / 2;
		offset = offset.floor();
		
		NodeRect nr;
		nr.node = Rect2(offset, s);
		nr.node_name = E;
		scroll_range = scroll_range.merge(nr.node); 
		
		nr.node.position -= state_machine->get_graph_offset() * EDSCALE;