nodes: 0, module; 1, function_definition; 2, function_name:mostCommonElement; 3, parameters; 4, block; 5, typed_parameter; 6, typed_default_parameter; 7, expression_statement; 8, class_definition; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, identifier:elements; 13, type; 14, identifier:to_hashable_f; 15, type; 16, None; 17, comment:"""
      Find the most frequent element of a collection.
  
      :param elements: An iterable of elements
      :param to_hashable_f: (optional) if defined will be used to get
          hashable presentation for non-hashable elements. Otherwise json.dumps
          is used with sort_keys=True
      :return: element which is the most frequent in the collection and
          the number of its occurrences
      """; 18, identifier:_Hashable; 19, argument_list; 20, block; 21, assignment; 22, assignment; 23, expression_list; 24, generic_type; 25, identifier:Callable; 26, attribute; 27, function_definition; 28, function_definition; 29, function_definition; 30, identifier:_elements; 31, generator_expression; 32, pattern_list; 33, subscript; 34, attribute; 35, identifier:counter; 36, identifier:Iterable; 37, type_parameter; 38, attribute; 39, identifier:Hashable; 40, function_name:__init__; 41, parameters; 42, block; 43, function_name:__eq__; 44, parameters; 45, block; 46, function_name:__hash__; 47, parameters; 48, block; 49, call; 50, for_in_clause; 51, identifier:most_common; 52, identifier:counter; 53, call; 54, integer:0; 55, identifier:most_common; 56, identifier:orig; 57, type; 58, identifier:collections; 59, identifier:abc; 60, identifier:self; 61, identifier:orig; 62, expression_statement; 63, if_statement; 64, identifier:self; 65, identifier:other; 66, return_statement; 67, identifier:self; 68, return_statement; 69, identifier:_Hashable; 70, argument_list; 71, identifier:el; 72, identifier:elements; 73, attribute; 74, argument_list; 75, identifier:T; 76, assignment; 77, call; 78, block; 79, elif_clause; 80, else_clause; 81, comparison_operator:self.hashable == other.hashable; 82, call; 83, identifier:el; 84, call; 85, identifier:most_common; 86, keyword_argument; 87, attribute; 88, identifier:orig; 89, identifier:isinstance; 90, argument_list; 91, expression_statement; 92, comparison_operator:to_hashable_f is not None; 93, block; 94, block; 95, attribute; 96, attribute; 97, identifier:hash; 98, argument_list; 99, identifier:Counter; 100, argument_list; 101, identifier:n; 102, integer:1; 103, identifier:self; 104, identifier:orig; 105, identifier:orig; 106, attribute; 107, assignment; 108, identifier:to_hashable_f; 109, None; 110, expression_statement; 111, expression_statement; 112, identifier:self; 113, identifier:hashable; 114, identifier:other; 115, identifier:hashable; 116, attribute; 117, identifier:_elements; 118, identifier:collections; 119, identifier:Hashable; 120, attribute; 121, identifier:orig; 122, assignment; 123, assignment; 124, identifier:self; 125, identifier:hashable; 126, identifier:self; 127, identifier:hashable; 128, attribute; 129, call; 130, attribute; 131, call; 132, identifier:self; 133, identifier:hashable; 134, identifier:to_hashable_f; 135, argument_list; 136, identifier:self; 137, identifier:hashable; 138, attribute; 139, argument_list; 140, identifier:orig; 141, identifier:json; 142, identifier:dumps; 143, identifier:orig; 144, keyword_argument; 145, identifier:sort_keys; 146, True
code: def mostCommonElement(elements: Iterable[T], to_hashable_f: Callable=None):
      """
      Find the most frequent element of a collection.
  
      :param elements: An iterable of elements
      :param to_hashable_f: (optional) if defined will be used to get
          hashable presentation for non-hashable elements. Otherwise json.dumps
          is used with sort_keys=True
      :return: element which is the most frequent in the collection and
          the number of its occurrences
      """
      class _Hashable(collections.abc.Hashable):
          def __init__(self, orig):
              self.orig = orig
  
              if isinstance(orig, collections.Hashable):
                  self.hashable = orig
              elif to_hashable_f is not None:
                  self.hashable = to_hashable_f(orig)
              else:
                  self.hashable = json.dumps(orig, sort_keys=True)
  
          def __eq__(self, other):
              return self.hashable == other.hashable
  
          def __hash__(self):
              return hash(self.hashable)
  
      _elements = (_Hashable(el) for el in elements)
      most_common, counter = Counter(_elements).most_common(n=1)[0]
      return most_common.orig, counter