### Godot version

4.1b

### System information

win11 Vulkan API 1.3.236

### Issue description

Selecting AnimationTree will result in error message 
`This function in this node can only be accessed from either the main thread or a thread group. Use call_deferred() instead.`

### Steps to reproduce

AnimationTree -> ROOT -> AnimationNodeStateMachine ->Add Animation.
There are several animations, clicking AnimationTree will result in several errors

### Minimal reproduction project

[test.zip](https://github.com/godotengine/godot/files/11708080/test.zip)

if (p_tree && !p_tree->is_connected("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed))) {
		p_tree->connect("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed), CONNECT_DEFERRED);
	}
	if (tree == p_tree) {
		return;
	}
	if (tree && tree->is_connected("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed))) {
		tree->disconnect("animation_player_changed", callable_mp(this, &AnimationTreeEditor::_animation_list_changed));
	}
	tree = p_tree;
	Vector<String> path;
	if (tree) {
		edit_path(path);
	}
}
void AnimationTreeEditor::_node_removed(Node *p_node) {