@isocam below is a sample script to demonstrate it. I changed the function to include only one parameter. Also, the method includes a list 'targetFolder' consisting of all the folder names to be looked for. If a file is present under any of these folders it returns the folder name else False.
import adsk.core, adsk.fusion, adsk.cam, traceback
def hasTargetFolder(doc: adsk.fusion.FusionDocument):
df: adsk.core.DataFolder = doc.dataFile.parentFolder
targetFolders = ["Purchased Parts", "Reference Parts", "Project Files"]
while True:
if df.isRoot:
break
if not df.parentFolder:
break
df = df.parentFolder
if df.name in targetFolders:
return df.name
return False
def run(context):
ui = None
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
document = design.parentDocument
print(hasTargetFolder(document))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
A suggestion to share code on the forum. Paste the code using the "Use the insert/Edif code sample" option and select the language type. This will make sure that all the indentations are maintained.

Hope it helps.
------------------------------------------------------------------------------------------------------------------------------
If my reply was helpful, please click the "Accept as Solution" button. It helps others get the answer quickly! A "Like" is always welcomed
Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.