<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def time_afterwards_preceding( self, when: datetime.datetime) -> Optional[datetime.timedelta]: """ Returns the time after our last interval, but before ``when``. If ``self`` is an empty list, returns ``None``. """

        if self.is_empty():
            return None
        end_time = self.end_datetime()
        if when <= end_time:
            return datetime.timedelta()
        else:
            return when - end_time