QualifiedName (@NotNull PyExpression superClassExpression) { if (superClassExpression instanceof PyReferenceExpression reference) { final String referenceName = reference.getName(); if (referenceName == null) { return PyPsiUtils.asQualifiedName(superClassExpression); } final Optional<QualifiedName> qualifiedName = StreamEx.of(PyResolveUtil.resolveLocally(reference)) .select(PyImportElement.class) .filter(element -> element.getAsName() != null) .map(PyImportElement::getImportedQName) .findAny(Objects::nonNull); if (qualifiedName.isPresent()) { return qualifiedName.get(); } } return PyPsiUtils.asQualifiedName(superClassExpression); }