public static List<File> removeRedundantPaths(List<File> files) throws IOException {
  final List<File> out=new ArrayList<>();
  final Set<String> paths=new HashSet<>();
  for (  File file : files) {
    if (paths.add(file.getCanonicalPath())) {
      out.add(file);
    }
  }
  return out;
}

public static List < File > removeRedundantPaths ( List < File > files ) throws IOException { final List < File > out = new ArrayList < > ( ) ; final Set < String > paths = new HashSet < > ( ) ; for ( File file : files ) { if ( paths . add ( file . getCanonicalPath ( ) ) ) { out . add ( file ) ; } } return out ; }
method to remove redundant canonical paths from a collection of files .
