code: def state(self, time=None):
          
          if time is None:
              return max(self.infos(type=State), key=attrgetter('creation_time'))
          else:
              states = [
                  s for s in self.infos(type=State) if s.creation_time < time]
              return max(states, key=attrgetter('creation_time'))
docs: The most recently-created info of type State at the specfied time.
  
          If time is None then it returns the most recent state as of now.