recombine if item has the same last_pos
break if same state is found