<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_containing_period(cls, *periods):
 """Given a bunch of TimePeriods, return a TimePeriod that most closely contains them."""


        if any(not isinstance(period, TimePeriod) for period in periods):
            raise TypeError("periods must all be TimePeriods: {}".format(periods))

        latest = datetime.datetime.min
        earliest = datetime.datetime.max

        for period in periods:
            # the best we can do to conain None is None!
            if period._latest is None:
                latest = None
            elif latest is not None and period._latest > latest:
                latest = period._latest

            if period._earliest is None:
                earliest = None
            elif earliest is not None and period._earliest < earliest:
                earliest = period._earliest

        return TimePeriod(earliest, latest)