def cloned_traverse(obj, opts, visitors):
 cloned = {}
 stop_on = set(opts.get('stop_on', []))
 def clone(elem):
  if (elem in stop_on):
   return elem
  else:
   if (id(elem) not in cloned):
    cloned[id(elem)] = newelem = elem._clone()
    newelem._copy_internals(clone=clone)
    meth = visitors.get(newelem.__visit_name__, None)
    if meth:
     meth(newelem)
   return cloned[id(elem)]
 if (obj is not None):
  obj = clone(obj)
 return obj

def cloned_traverse ( obj , opts , visitors ) : cloned = { } stop_on = set ( opts . get ( 'stop_on' , [ ] ) ) def clone ( elem ) : if ( elem in stop_on ) : return elem else : if ( id ( elem ) not in cloned ) : cloned [ id ( elem ) ] = newelem = elem . _clone ( ) newelem . _copy_internals ( clone = clone ) meth = visitors . get ( newelem . __visit_name__ , None ) if meth : meth ( newelem ) return cloned [ id ( elem ) ] if ( obj is not None ) : obj = clone ( obj ) return obj
clone the given expression structure .