public void invoke(boolean unqualifyAll) {
      final Project project = myImportElement.getProject();

      final PyElementGenerator generator = PyElementGenerator.getInstance(project);
      final LanguageLevel languageLevel = LanguageLevel.forElement(myImportElement);

      // usages of imported name are qualifiers; what they refer to?
      try {
        // remember names and make them drop qualifiers
        final Set<String> usedNames = new HashSet<>();
        Collection<PyReferenceExpression> referencesToUpdate = unqualifyAll ? myReferences : getSameNameReferences();
        for (PyReferenceExpression ref : referencesToUpdate) {
          final PsiElement parentElt = ref.getParent();
          assert parentElt instanceof PyReferenceExpression: parentElt.getClass();
          final String nameUsed = Objects.requireNonNull(((PyReferenceExpression)parentElt).getReferencedName());
          usedNames.add(nameUsed);
          final PyElement newReference = generator.createExpressionFromText(languageLevel, nameUsed);
          parentElt.replace(newReference);
        }

        // create a separate import stmt for the module
        final PsiElement importer = myImportElement.getParent();
        final PyImportStatementBase importStatement;
        final PyImportElement[] importElements;
        if (importer instanceof PyImportStatement qualifiedImportStatement) {
          importStatement = qualifiedImportStatement;
          importElements = importStatement.getImportElements();
        }
        else if (importer instanceof PyFromImportStatement fromImportStatement) {
          importStatement = fromImportStatement;
          importElements = importStatement.getImportElements();
        }
        else {
          throw new IncorrectOperationException("Not an import at all");
        }
        final PyFromImportStatement newImportStatement =
          generator.createFromImportStatement(languageLevel, myNewImportSource, StringUtil.join(usedNames, ", "), null);
        final PsiElement parent = importStatement.getParent();
        boolean canRemoveImport = !myHasModuleReference && referencesToUpdate.size() == myReferences.size();
        if (importElements.length == 1) {
          if (!canRemoveImport) {
            parent.addAfter(newImportStatement, importStatement); // add 'import from': we need the module imported as is
          }
          else { // replace entire existing import
            importStatement.replace(newImportStatement);
          }
        }
        else {
          if (canRemoveImport) {
            // cut the module out of import, add a from-import.
            myImportElement.delete();
          }
          parent.addAfter(newImportStatement, importStatement);
        }
      }
      catch (IncorrectOperationException ignored) {
        PythonUiService.getInstance().showBalloonWarning(project, PyPsiBundle.message("QFIX.action.failed"));
      }
    }
public void invoke(boolean unqualifyAll)