nodes: 0, module; 1, function_definition; 2, function_name:truncate_most_common; 3, parameters; 4, block; 5, identifier:self; 6, identifier:truncation_length; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, string; 11, assignment; 12, identifier:key; 13, call; 14, block; 15, string_content:Sorts the counter and keeps only the most common items up to
          ``truncation_length`` in place.
  
          :type truncation_length: int; 16, identifier:keep_keys; 17, call; 18, attribute; 19, argument_list; 20, if_statement; 21, identifier:set; 22, generator_expression; 23, identifier:self; 24, identifier:keys; 25, comparison_operator:key not in keep_keys; 26, block; 27, subscript; 28, for_in_clause; 29, identifier:key; 30, identifier:keep_keys; 31, expression_statement; 32, identifier:v; 33, integer:0; 34, identifier:v; 35, call; 36, call; 37, attribute; 38, argument_list; 39, attribute; 40, argument_list; 41, identifier:self; 42, identifier:most_common; 43, identifier:truncation_length; 44, identifier:self; 45, identifier:pop; 46, identifier:key
code: def truncate_most_common(self, truncation_length):
          '''
          Sorts the counter and keeps only the most common items up to
          ``truncation_length`` in place.
  
          :type truncation_length: int
          '''
          keep_keys = set(v[0] for v in self.most_common(truncation_length))
          for key in self.keys():
              if key not in keep_keys:
                  self.pop(key)