code: def get_messages(self):
          
          if not self._messages:  # if not already cached
              query = self._dbman.query('thread:' + self._id)
              thread = next(query.search_threads())
  
              def accumulate(acc, msg):
                  M = Message(self._dbman, msg, thread=self)
                  acc[M] = []
                  r = msg.get_replies()
                  if r is not None:
                      for m in r:
                          acc[M].append(accumulate(acc, m))
                  return M
  
              self._messages = {}
              for m in thread.get_toplevel_messages():
                  self._toplevel_messages.append(accumulate(self._messages, m))
          return self._messages
docs: returns all messages in this thread as dict mapping all contained
          messages to their direct responses.
  
          :rtype: dict mapping :class:`~alot.db.message.Message` to a list of
                  :class:`~alot.db.message.Message`.