Suppose I have an ArrayList, which has paths to the specific file to be processed. But this file can only be proccessed, if there's only one in a folder. Here's what I mean:
My ArrayList
List<String> pathsToTheFile = new ArrayList<>();
has
C:\123\456\NameOfUniqueFolder0
C:\123\456\NameOfUniqueFolder1
C:\123\456\NameOfUniqueFolder2
C:\123\456\NameOfUniqueFolder3
C:\123\456\NameOfUniqueFolder4
Suppose my 5th element is
C:\123\456\NameOfUniqueFolder0
Obviosuly, it's a duplicate of my 0 element, since the file inside this folder SHOULD NOT be proccessed at all. C:\123\456\NameOfUniqueFolder0 should be removed form the list. I can not use a SET here, because it will "remove" the duplicate, but one path to the folder will be still there, and the file inside get proccessed.