<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter(self, dates=None, min_dets=1):
 """ Return a new Party filtered according to conditions. Return a new Party with only detections within a date range and only families with a minimum number of detections. :type dates: list of obspy.core.UTCDateTime objects :param dates: A start and end date for the new Party :type min_dets: int :param min_dets: Minimum number of detections per family .. rubric:: Example """

        if dates is None:
            raise MatchFilterError('Need a list defining a date range')
        new_party = Party()
        for fam in self.families:
            new_fam = Family(
                template=fam.template,
                detections=[det for det in fam if
                            dates[0] < det.detect_time < dates[1]])
            if len(new_fam) >= min_dets:
                new_party.families.append(new_fam)
        return new_party