def record_drop_duplicate_fields(record):
out = {}<EOL>position = <NUM_LIT:0><EOL>tags = sorted(record.keys())<EOL>for tag in tags:<EOL><INDENT>fields = record[tag]<EOL>out[tag] = []<EOL>current_fields = set()<EOL>for full_field in fields:<EOL><INDENT>field = (tuple(full_field[<NUM_LIT:0>]),) + full_field[<NUM_LIT:1>:<NUM_LIT:4>]<EOL>if field not in current_fields:<EOL><INDENT>current_fields.add(field)<EOL>position += <NUM_LIT:1><EOL>out[tag].append(full_field[:<NUM_LIT:4>] + (position,))<EOL><DEDENT><DEDENT><DEDENT>return out<EOL>
Return a record where all the duplicate fields have been removed.

Fields are considered identical considering also the order of their
subfields.