private static PsiImportStatementBase findExistingImport(PsiFile file, PsiClass aClass, String refName) {
    if (file instanceof PsiJavaFile && aClass != null) {
      PsiImportList importList = ((PsiJavaFile)file).getImportList();
      if (importList != null) {
        for (PsiImportStaticStatement staticStatement : importList.getImportStaticStatements()) {
          if (staticStatement.isOnDemand()) {
            if (aClass.isEquivalentTo(staticStatement.resolveTargetClass())) {
              return staticStatement;
            }
          }
        }

        final PsiImportStatementBase importStatement = importList.findSingleImportStatement(refName);
        if (importStatement instanceof PsiImportStaticStatement &&
            aClass.isEquivalentTo(((PsiImportStaticStatement)importStatement).resolveTargetClass())) {
          return importStatement;
        }
      }
    }
    return null;
  }
private static PsiImportStatementBase findExistingImport(PsiFile file, PsiClass aClass, String refName)