def _remove(target, delete):
    """
    Removes fields from the target.
    :param target: the JSON schema to remove fields from.
    :param delete: the JSON schema fields to remove
    :return: the target minus the delete fields.
    """
    for k, v in delete.items():
        dv = target.get(k)
        if dv is not None:
            if k == 'required':
                for req in v:
                    target['properties'].pop(req, None)
                target[k] = [i for i in target[k] if i not in v]  # quadratic performance, optimize
            elif isinstance(v, dict):
                target[k] = _remove(dv, v)
            elif isinstance(v, list):
                target[k] = [i for i in dv if i not in v]  # quadratic performance, optimize
    return target