def METHOD_NAME(candidate, cycle, district=None):
    if cycle:
        if candidate['office'] == 'H':
            if candidate.get('state') and candidate.get('district'):
                district_url = '/' + str(candidate['state']) + '/' + candidate['district']
            else:
                return None
        elif candidate['office'] == 'S':
            if candidate.get('state'):
                district_url = '/' + str(candidate['state'])
            else:
                return None
        else:
            district_url = ''
        return '/data/elections/' + candidate['office_full'].lower() + district_url + '/' + str(cycle)
    else:
        return None