def METHOD_NAME(p):
  '''
  Fix pickles from Python 2
  Version 3
  Parameters
  ----------
  p: pickle
  Returns
  -------
  p: the fixed pickle
  Comments:
  ---------
  '''
  from mmtbx.model.model import get_hierarchy_and_run_hierarchy_method
  from collections.abc import Mapping, MutableSequence
  from libtbx import group_args
  from scitbx_array_family_flex_ext import std_string
  if isinstance(p, get_hierarchy_and_run_hierarchy_method):
    return p
  if isinstance(p, group_args):
    p = p() # now it is a dict
    for key in list(p.keys()):    # fix the key
      if isinstance(key, bytes):
        str_key = key.decode('utf8')
        p[str_key] = p[key]
        del p[key]
        key = str_key
      p[key] = METHOD_NAME(p[key])
    # convert to dict, fix, convert back to group args
    p = group_args(**p)
  elif isinstance(p, bytes):
    p = p.decode('utf8')
  elif isinstance(p, MutableSequence):
    for i in range(len(p)):
      p[i] = METHOD_NAME(p[i])
  elif isinstance(p, Mapping):
    for key in list(p.keys()):    # fix the key
      if isinstance(key, bytes):
        str_key = key.decode('utf8')
        p[str_key] = p[key]
        del p[key]
        key = str_key
      p[key] = METHOD_NAME(p[key])
  elif isinstance(p,tuple):
    p = tuple(METHOD_NAME(list(p)))
  elif isinstance(p, std_string):
    new_p = std_string()
    for x in p:
      new_p.append(METHOD_NAME(x))
    p = new_p
  # Classes like mmtbx.monomer_library.cif_types.chem_mod_angle remain here
  elif hasattr(p, '__dict__'):
    for key in list(p.__dict__.keys()):    # fix the key
      if isinstance(key, bytes):
        str_key = key.decode('utf8')
        p.__dict__[str_key] = p.__dict__[key]
        del p.__dict__[key]
        key = str_key
      if not key.startswith("__"):
        p.__dict__[key] = METHOD_NAME(p.__dict__[key])
  else:
    # We have no idea...skip conversion (should never be here)
    pass
  return p