### 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
Color fade_linecolor = accent;
		fade_linecolor.set_hsv(1.0, fade_linecolor.get_s(), fade_linecolor.get_v());
		state_machine_draw->draw_line(p_from, p_from.lerp(p_to, p_fade_ratio), fade_linecolor, 2);
	}
	Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
	Transform2D xf;
	xf.columns[0] = (p_to - p_from).normalized();
	xf.columns[1] = xf.columns[0].orthogonal();
	xf.columns[2] = (p_from + p_to) * 0.5 - xf.columns[1] * icon->get_height() * 0.5 - xf.columns[0] * icon->get_height() * 0.5;
	state_machine_draw->draw_set_transform_matrix(xf);
	if (p_multi_transitions) {
		state_machine_draw->draw_texture(icons[0], Vector2(-icon->get_width(), 0), icon_color);
		state_machine_draw->draw_texture(icons[0], Vector2(), icon_color);
		state_machine_draw->draw_texture(icons[0], Vector2(icon->get_width(), 0), icon_color);
	} else {
		state_machine_draw->draw_texture(icon, Vector2(), icon_color);
	}
	state_machine_draw->draw_set_transform_matrix(Transform2D());
}
void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, const Vector2 &p_to, const Rect2 &p_rect) {
	if (p_to == r_from) {
		return;
	}
	
	Vector2 n = (p_to - r_from).normalized();
	while (p_rect.has_point(r_from)) {
		r_from += n;
	}
}
void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(const Vector2 &p_from, Vector2 &r_to, const Rect2 &p_rect) {