private static PsiImportStatement findUnusedSingleImport(@NotNull PsiJavaFile file, @NotNull String shortName, @NotNull String fqName) {
    PsiImportList importList = file.getImportList();
    if (importList != null) {
      for (PsiImportStatement statement : importList.getImportStatements()) {
        PsiJavaCodeReferenceElement ref = statement.getImportReference();
        if (!statement.isOnDemand() && ref != null && shortName.equals(ref.getReferenceName()) &&
            !fqName.equals(statement.getQualifiedName())) {
          PsiElement target = statement.resolve();
          if (target instanceof PsiClass) {
            Collection<PsiReference> all = ReferencesSearch.search(target, new LocalSearchScope(file)).findAll();
            if (all.size() == 1 && PsiTreeUtil.isAncestor(statement, all.iterator().next().getElement(), true)) {
              return statement;
            }
          }
        }
      }
    }
    return null;
  }
private static PsiImportStatement findUnusedSingleImport(@NotNull PsiJavaFile file, @NotNull String shortName, @NotNull String fqName)