def strip_empty(document, required=tuple()):
    new_doc = {}
    for k, v in document.items():
        if k in required:
            new_doc[k] = v
        else:
            new_val = do_strip_empty(v)
            if k == 'otherProperties':
                new_val = [property for property in new_val if property.get('properties')]
            if new_val:
                new_doc[k] = new_val
    return new_doc
Removes empty fields from the processed schema
dataset/ETHPy150Open CenterForOpenScience/scrapi/scrapi/linter/document.py/strip_empty