def get_registered_from(registration):
    if registration.registered_from:
        return registration.registered_from_id
    else:
        first_log_id = db['node'].find_one({'_id': registration._id})['logs'][0]
        log = NodeLog.load(first_log_id)
        return log.params.get('node') or log.params.get('project')
Gets node registration was registered from.  Handles deleted registrations where registered_from is null.
dataset/ETHPy150Open CenterForOpenScience/osf.io/scripts/migrate_registration_logs.py/get_registered_from