'Clone an arbitrary object; used by L{Tag.clone}.
@param obj: an object with a clone method, a list or tuple, or something
which should be immutable.
@param deep: whether to continue cloning child objects; i.e. the
contents of lists, the sub-tags within a tag.
@return: a clone of C{obj}.'

def _clone(self, obj, deep):

    if hasattr(obj, 'clone'):
        return obj.clone(deep)
    elif isinstance(obj, (list, tuple)):
        return [self._clone(x, deep) for x in obj]
    else:
        return obj
