detect and merge duplicates caused by train ID changes