def attribute(rl, attribute, type, threshold):
    """ Returns all repeats in ``rl`` with a attribute below (above) a certain
        threshold.

    Returns all repeats in ``rl`` with a attribute below (above) a certain
    threshold.

    Args:
        rl (RepeatList): An instance of the RepeatList class.
        attribute (str): The attribute of the Repeat instance
        type (str): Either "min" or "max"
        threshold (float): All repeats with an attribute value below (above)
                          this threshold are filtered out.
    """
    threshold = float(threshold)
    res = []
    for i_repeat in rl.repeats:
        value = getattr(i_repeat, attribute)
        if type == 'min':
            if value >= threshold:
                res.append(i_repeat)
        elif type == 'max':
            if value <= threshold:
                res.append(i_repeat)
        else:
            raise Exception(
                "type must either be 'min' or 'max'. Instead, it is {}.".
                format(type))
    return res
