<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _migrate_subresource(subresource, parent, migrations):
 """ Migrate a resource's subresource :param subresource: the perch.SubResource instance :param parent: the parent perch.Document instance :param migrations: the migrations for a resource """

    for key, doc in getattr(parent, subresource.parent_key, {}).items():
        for migration in migrations['migrations']:
            instance = migration(subresource(id=key, **doc))
            parent._resource['doc_version'] = unicode(migration.version)

            instance = _migrate_subresources(
                instance,
                migrations['subresources']
            )

        doc = instance._resource
        doc.pop('id', None)
        doc.pop(instance.resource_type + '_id', None)

        getattr(parent, subresource.parent_key)[key] = doc

    return parent