<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_dates(dates, time_difference):
 """ Filters out dates within time_difference, preserving only the oldest date. :param dates: a list of datetime objects :param time_difference: a ``datetime.timedelta`` representing the time difference threshold :rtype: list(datetime.datetime) """


        LOGGER.debug("dates=%s", dates)

        if len(dates) <= 1:
            return dates

        sorted_dates = sorted(dates)

        separate_dates = [sorted_dates[0]]
        for curr_date in sorted_dates[1:]:
            if curr_date - separate_dates[-1] > time_difference:
                separate_dates.append(curr_date)
        return separate_dates