def METHOD_NAME(user, hierarchy_org, organisations):
    hierarchy_org_id = hierarchy_org.pk if hierarchy_org is not None else 0
    org_ids = ','.join(sorted({str(org.pk) for org in organisations.only('pk')}))
    key = 'user_filtered_projects:{}:{}:{}'.format(user.id, hierarchy_org_id, org_ids)
    return key