def get_attributes_threshold(attributes, alist, decreasingFactor, maxActivityCount = 25):
    """
    Get attributes cutting threshold

    Parameters
    ----------
    attributes
        Dictionary of attributes associated with their count
    alist
        Sorted attributes list

    Returns
    ---------
    threshold
        Activities cutting threshold
    """

    threshold = alist[0][1]
    i = 1
    while i < len(alist):
        value = alist[i][1]
        if value > threshold * decreasingFactor:
            threshold = value
        if i >= maxActivityCount:
            break
        i = i + 1
    return threshold