def _deep_annotate(element, annotations, exclude=None):
 def clone(elem):
  if (exclude and hasattr(elem, 'proxy_set') and elem.proxy_set.intersection(exclude)):
   newelem = elem._clone()
  elif (annotations != elem._annotations):
   newelem = elem._annotate(annotations)
  else:
   newelem = elem
  newelem._copy_internals(clone=clone)
  return newelem
 if (element is not None):
  element = clone(element)
 return element

def _deep_annotate ( element , annotations , exclude = None ) : def clone ( elem ) : if ( exclude and hasattr ( elem , 'proxy_set' ) and elem . proxy_set . intersection ( exclude ) ) : newelem = elem . _clone ( ) elif ( annotations != elem . _annotations ) : newelem = elem . _annotate ( annotations ) else : newelem = elem newelem . _copy_internals ( clone = clone ) return newelem if ( element is not None ) : element = clone ( element ) return element
deep copy the given clauseelement .