def mostCommonElement(elements: Iterable[T], to_hashable_f: Callable=None):
    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