<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def longest_duration(self) -> Optional[datetime.timedelta]: """ Returns the duration of the longest interval, or None if none. """

        if not self.intervals:
            return None
        return max(self.durations())