import requests


def get_so_accession_dict(page_size=500):
    """Get name and accession of all hierarchical descendents of sequence_variant in the Sequence Ontology."""
    sequence_variant_id = 'SO:0001060'
    url = f'https://www.ebi.ac.uk/ols/api/ontologies/so/hierarchicalDescendants?id={sequence_variant_id}&size={page_size}'
    has_next = True
    results = []
    while has_next:
        response = requests.get(url)
        response.raise_for_status()
        response_json = response.json()
        results += response_json['_embedded']['terms']
        has_next = 'next' in response_json['_links']
        if has_next:
            url = response_json['_links']['next']['href']
    return {
        r['label']: r['short_form']
        for r in results
    }