private static @Nullable DirectoryChooser.ItemWrapper chooseSelection(final VirtualFile initialTargetDirectorySourceRoot,
                                                                        final ProjectFileIndex fileIndex,
                                                                        final ArrayList<DirectoryChooser.ItemWrapper> items,
                                                                        final DirectoryChooser.ItemWrapper initial,
                                                                        final DirectoryChooser.ItemWrapper oldOne) {
    if (initial != null || ((initialTargetDirectorySourceRoot == null || items.size() > 2) && items.contains(
      DirectoryChooser.ItemWrapper.NULL)) || items.isEmpty()) {
      return initial;
    }
    else {
      if (oldOne != null) {
        return oldOne;
      }
      else if (initialTargetDirectorySourceRoot != null) {
        final boolean inTest = fileIndex.isInTestSourceContent(initialTargetDirectorySourceRoot);
        for (DirectoryChooser.ItemWrapper item : items) {
          PsiDirectory directory = item.getDirectory();
          if (directory != null) {
            final VirtualFile virtualFile = directory.getVirtualFile();
            if (fileIndex.isInTestSourceContent(virtualFile) == inTest) {
              return item;
            }
          }
        }
        if (items.contains(DirectoryChooser.ItemWrapper.NULL)) return DirectoryChooser.ItemWrapper.NULL;
      }
    }
    return items.get(0);
  }
private static @Nullable DirectoryChooser.ItemWrapper chooseSelection(final VirtualFile initialTargetDirectorySourceRoot,
                                                                        final ProjectFileIndex fileIndex,
                                                                        final ArrayList<DirectoryChooser.ItemWrapper> items,
                                                                        final DirectoryChooser.ItemWrapper initial,
                                                                        final DirectoryChooser.ItemWrapper oldOne)