def collect_codelist_values(path, data, pointer=''):
    """
    Collects ``codelist`` values from JSON Schema.
    From https://github.com/open-contracting/jscc/blob/main/jscc/testing/checks.py#L674
    """
    codelists = set()

    if isinstance(data, list):
        for index, item in enumerate(data):
            codelists.update(collect_codelist_values(path, item, pointer='{}/{}'.format(pointer, index)))
    elif isinstance(data, dict):
        if 'codelist' in data:
            codelists.add(data['codelist'])

        for key, value in data.items():
            codelists.update(collect_codelist_values(path, value, pointer='{}/{}'.format(pointer, key)))

    return codelists