

def find_and_create_file_from_metadata(children, source, destination, destination_node, obj):
    ' Given a Guid obj, recursively search for the metadata of its referent (a file obj)\n    in the waterbutler response. If found, create a new addon FileNode with that metadata\n    and return the new file.\n    '
    for item in children:
        if (not item['materialized'].startswith('/')):
            item['materialized'] = ('/' + destination_node['materialized'])
        if (item['kind'] == 'folder'):
            return find_and_create_file_from_metadata(item.get('children', []), source, destination, destination_node, obj)
        elif ((item['kind'] == 'file') and (item['materialized'].replace(destination['materialized'], source['materialized']) == obj.referent.materialized_path)):
            data = dict(item)
            new_file = FileNode.resolve_class(destination['provider'], FileNode.FILE).get_or_create(destination_node, item['path'])
            if (destination['provider'] != 'osfstorage'):
                new_file.update(revision=None, data=data)
            return new_file

dataset/ETHPy150Open CenterForOpenScience/osf.io/website/project/views/comment.py find_and_create_file_from_metadata/VarMisuse@51/154 `item`->`destination_node`