def copy_files(src, target_node, parent=None, name=None):
    assert not parent or not parent.is_file, 'Parent must be a folder'

    cloned = src.clone().wrapped()
    cloned.parent = parent
    cloned.node = target_node
    cloned.name = name or cloned.name

    if src.is_file:
        cloned.versions = src.versions

    cloned.save()

    if not src.is_file:
        for child in src.children:
            copy_files(child, target_node, parent=cloned)

    return cloned
Copy the files from src to the target node
dataset/ETHPy150Open CenterForOpenScience/osf.io/website/files/utils.py/copy_files