int (@Nullable VirtualFile v1, @Nullable VirtualFile v2) { if (!Objects.equals(v1, v2)) { if (v1 == null) { return -1; } if (v2 == null) { return 1; } VirtualFile[] parents1 = getPathComponents(v1); VirtualFile[] parents2 = getPathComponents(v2); for (int i = 0; i < Math.min(parents1.length, parents2.length); i++) { if (!parents1[i].equals(parents2[i])) { return parents1[i].getName().compareTo(parents2[i].getName()); } } return v1.getName().compareTo(v2.getName()); } return 0; }