def _copyRecursive(syn, entity, destinationId, mapping = dict(), **kwargs):
    """
    Recursively copies synapse entites, but does not copy the wikis

    :param entity:             A synapse entity ID

    :param destinationId:      Synapse ID of a folder/project that the copied entity is being copied to

    :param mapping:            Takes a mapping {'oldSynId': 'newSynId'} to help with copying syn ids that aren't already part of the entity
                               Default to dict() and builds the mapping of all the synapse entities copied
    """

    version = kwargs.get('version', None)
    setProvenance = kwargs.get('setProvenance', "traceback")
    recursive = kwargs.get('recursive',True)
    copyTable = kwargs.get('copyTable',True)
    replace = kwargs.get('replace',False)

    ent = syn.get(entity,downloadFile=False)
    if isinstance(ent, Project):
        if destinationId is None:
            newProject = syn.store(Project("Copied %s %s" %(time.time(),ent.name)))
            destinationId = newProject.id
        elif not isinstance(syn.get(destinationId),Project):
            raise ValueError("You must give a destinationId of a new project to copy projects")
        copiedId = destinationId
        entities = syn.chunkedQuery('select id, name from entity where parentId=="%s"' % ent.id)
        for i in entities:
            mapping = _copyRecursive(syn, i['entity.id'], destinationId, mapping=mapping, **kwargs)
    else:
        if destinationId is None:
            raise ValueError("You must give a destinationId unless you are copying a project")
        elif isinstance(ent, Folder):
            copiedId = _copyFolder(syn, ent.id, destinationId, mapping=mapping, **kwargs)
        elif isinstance(ent, File):
            copiedId = _copyFile(syn, ent.id, destinationId, version=version, replace=replace, setProvenance=setProvenance)
        elif isinstance(ent, Link):
            copiedId = _copyLink(syn, ent.id, destinationId)
        elif isinstance(ent, Schema) and copyTable:
            copiedId = _copyTable(syn, ent.id, destinationId)
        else:
            raise ValueError("Not able to copy this type of file")

    print("Copied %s to %s" % (ent.id,copiedId))
    mapping[ent.id] = copiedId
    return(mapping)
dataset/ETHPy150Open Sage-Bionetworks/synapsePythonClient/synapseutils/copy.py/_copyRecursive/original