code: def freeze(o):
      
      if isinstance(o, (tuple, list)):
          return tuple(sorted(freeze(e) for e in o))
  
      if isinstance(o, dict):
          return tuple(sorted((k, freeze(v)) for k, v in iteritems(o)))
  
      if isinstance(o, (set, frozenset)):
          return tuple(sorted(freeze(e) for e in o))
  
      return o
docs: Freezes any mutable object including dictionaries and lists for hashing.
      Accepts nested dictionaries.