def get_minsep_range(minseps, cap=None):
    """
    Create ranged minseps from an ensemble of minsep entries

    Args:
        minseps (list): A list of minsep dictionaries
        cap (tuple): Minimum-maximum caps

    Returns:
        minsep (dict): A minsep where values are minimum and maximum values
    """

    base = {key: [value, value] for key, value in minseps[0].items()}
    for minsep in minseps:
        for key, value in minsep.items():
            # If the key exists (it should)
            if key in base:
                existing = base[key]
                # Expand the minimum and maximum values
                if cap and (value < cap[0]):
                    existing[0] = cap[0]
                elif cap and (value > cap[1]):
                    existing[1] = cap[1]
                elif existing[0] > value:
                    existing[0] = value
                elif existing[1] < value:
                    existing[1] = value
            # add the pairs if needed
            else:
                base[key] = [value, value]
    return base