When scanning a file / set tracks are iterated and handled differently based on the is_foldable field. In the case where it foldable it is locally defined as group and in the case where it isn't it is defined as track. Later in the function it is assumed that track is already defined. However this won't be the case if the track was foldable / was a group. As a result the follow error is raised:
for device_index, device_data in enumerate(track_data["devices"]):
> device = Device(track, device_index, device_data["name"])
E UnboundLocalError: local variable 'track' referenced before assignment
To reproduce: add a device to a Group and then try to instantiate a Set with scan=True