Got rid of adjacent duplicates in an instance of ArrayList