def get_KEGG_comps(db, kegg_db, model_ids):
    """Get KEGG IDs from KEGG MINE database for compounds in model(s)."""
    kegg_ids, _ids = set(), set()
    for model_id in model_ids:
        comp_ids = kegg_db.models.find_one({'_id': model_id}, {'Compounds': 1}
            )['Compounds']
        for comp_id in comp_ids:
            kegg_ids.add(comp_id)
    for kegg_id in kegg_ids:
        for comp in db.compounds.find({'DB_links.KEGG': kegg_id}, {'_id': 1}):
            _ids.add(comp['_id'])
    return _ids
