If (all) are met ... If (all) are met for (the enclosing folder) Name matches (• parent name)
where (• parent name) is a custom text attribute which is set to match "anything". See the manual on how to do a nested condition.
What the above does is store the name of the parent folder into that attribute. You can then reference that attribute in the Add Tags action via a dynamic tag.