Python detect duplicate Docs

The solution I came up with is doing a query then detecting if the query brings back a document. I feel this is clunky, but works. If I determine there is a match, I will return the objectID, for post-processing

def db_query_for_existing_HW(env_hw):  
    env = env_hw()
    myclient = MongoClient(env.connection_string)
    mydb = myclient[env.db_name]
    col_hw = mydb[env.col_name_hw]
		#open current HW Manifest
    with open(env.manifest_path) as f:
        data = json.load(f)
    length = len(data['system board'])
    dict_systemboard = create_HW_dicts(data, "system board", length)
    length = len(data['cpu'])
    dict_cpus = create_HW_dicts(data, "cpu", length)
    
	q = {
        "system board.description": dict_systemboard['description'],
        "cpu.code_name": dict_cpus['code_name']
    }
    myquery = col_hw.find(q)
    for x in myquery:
        env.match=True
    return env