def is_cwl_record(d):
    """Check if an input is a CWL record, from any level of nesting.
    """
    if isinstance(d, dict):
        if d.get("type") == "record":
            return d
        else:
            recs = list(filter(lambda x: x is not None, [is_cwl_record(v) for v in d.values()]))
            return recs[0] if recs else None
    else:
        return None