def get_clustering_level(clustering):
    """
    Returns the numbers of levels in the clustering.
    Intended to be used as an upper bound for 1-based `max_level` in clustering preprocessing.
    """
    levels = []
    for el in clustering:
        if isinstance(el, dict):
            levels.append(get_clustering_level(el['references']))
    if not levels:
        return 1
    else:
        return max(levels) + 1