Tag folder based on its contents directly

In my folder structure, in the Documents folder, I have Xcode projects. An Xcode project is a folder with a bunch of files in it including a .xcodeproj file.
These projects can be at any depth anywhere in the folder structure. So in order to check if a folder is a project I have to check if it contains an Xcode Project file. If the folder is a project then I want to add the "Code" tag to it.
I tried the following rules but the problem is that this marks the topmost folder as "code".
https://ibb.co/gZWsZmg
https://ibb.co/LgHnSdy
How can I mark a folder that directly contains an Xcode project file?
These projects can be at any depth anywhere in the folder structure. So in order to check if a folder is a project I have to check if it contains an Xcode Project file. If the folder is a project then I want to add the "Code" tag to it.
I tried the following rules but the problem is that this marks the topmost folder as "code".
https://ibb.co/gZWsZmg
https://ibb.co/LgHnSdy
How can I mark a folder that directly contains an Xcode project file?