<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _nest_variable(v, check_records=False):
 """Nest a variable when moving from scattered back to consolidated. check_records -- avoid re-nesting a record input if it comes from a previous step and is already nested, don't need to re-array. """

    if (check_records and is_cwl_record(v) and len(v["id"].split("/")) > 1 and
         v.get("type", {}).get("type") == "array"):
        return v
    else:
        v = copy.deepcopy(v)
        v["type"] = {"type": "array", "items": v["type"]}
        return v