### 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)

return button_path;
}
void AnimationTreeEditor::enter_editor(const String &p_path) {
	Vector<String> path = edited_path;
	path.push_back(p_path);
	edit_path(path);
}
void AnimationTreeEditor::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {
			get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
		} break;
		case NOTIFICATION_PROCESS: {
			ObjectID root;
			if (tree && tree->get_tree_root().is_valid()) {
				root = tree->get_tree_root()->get_instance_id();
			}
			if (root != current_root) {
				edit_path(Vector<String>());
			}
			if (button_path.size() != edited_path.size()) {
				edit_path(edited_path);
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {
			get_tree()->disconnect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
		} break;
	}
}
void AnimationTreeEditor::_bind_methods() {