nodes: 0, module; 1, function_definition; 2, function_name:_list; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, function_definition; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, return_statement; 16, identifier:foldername; 17, string:"INBOX"; 18, identifier:reverse; 19, False; 20, identifier:since; 21, None; 22, comment:"""Do structured list output.
  
          Sorts the list by date, possibly reversed, filtered from 'since'.
  
          The returned list is: foldername, message key, message object
          """; 23, assignment; 24, function_name:sortcmp; 25, parameters; 26, block; 27, assignment; 28, assignment; 29, assignment; 30, identifier:itemlist; 31, identifier:folder; 32, conditional_expression:self.folder \
              if foldername == "INBOX" \
              else self._getfolder(foldername); 33, identifier:d; 34, try_statement; 35, identifier:lst; 36, conditional_expression:folder.items() if not since else folder.items_since(since); 37, identifier:sorted_lst; 38, call; 39, identifier:itemlist; 40, list_comprehension; 41, attribute; 42, line_continuation:\; 43, comparison_operator:foldername == "INBOX"; 44, line_continuation:\; 45, call; 46, block; 47, except_clause; 48, call; 49, not_operator; 50, call; 51, identifier:sorted; 52, argument_list; 53, tuple; 54, for_in_clause; 55, identifier:self; 56, identifier:folder; 57, identifier:foldername; 58, string:"INBOX"; 59, attribute; 60, argument_list; 61, return_statement; 62, block; 63, attribute; 64, argument_list; 65, identifier:since; 66, attribute; 67, argument_list; 68, identifier:lst; 69, keyword_argument; 70, keyword_argument; 71, identifier:folder; 72, identifier:key; 73, identifier:msg; 74, pattern_list; 75, identifier:sorted_lst; 76, identifier:self; 77, identifier:_getfolder; 78, identifier:foldername; 79, attribute; 80, return_statement; 81, identifier:folder; 82, identifier:items; 83, identifier:folder; 84, identifier:items_since; 85, identifier:since; 86, identifier:key; 87, identifier:sortcmp; 88, identifier:reverse; 89, conditional_expression:1 if reverse else 0; 90, identifier:key; 91, identifier:msg; 92, subscript; 93, identifier:date; 94, unary_operator; 95, integer:1; 96, identifier:reverse; 97, integer:0; 98, identifier:d; 99, integer:1; 100, integer:1
code: def _list(self, foldername="INBOX", reverse=False, since=None):
          """Do structured list output.
  
          Sorts the list by date, possibly reversed, filtered from 'since'.
  
          The returned list is: foldername, message key, message object
          """
          folder = self.folder \
              if foldername == "INBOX" \
              else self._getfolder(foldername)
  
          def sortcmp(d):
              try:
                  return d[1].date
              except:
                  return -1
  
          lst = folder.items() if not since else folder.items_since(since)
          sorted_lst = sorted(lst, key=sortcmp, reverse=1 if reverse else 0)
          itemlist = [(folder, key, msg) for key,msg in sorted_lst]
          return itemlist