ullable
  public static QualifiedName getFullQualifiedName(@Nullable final PsiElement element) {
    final String name =
      (element instanceof PsiNamedElement) ? ((PsiNamedElement)element).getName() : element != null ? element.getText() : null;
    if (name != null) {
      final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
      final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(element);
      if (owner instanceof PyClass) {
        final QualifiedName importQName = QualifiedNameFinder.findCanonicalImportPath(element, element);
        if (importQName != null) {
          return QualifiedName.fromDottedString(importQName + "." + owner.getName() + "." + name);
        }
      }
      else if (PyUtil.isInitOrNewMethod(owner)) {
        final QualifiedName importQName = QualifiedNameFinder.findCanonicalImportPath(owner, element);
        final PyClass containingClass = ((PyFunction)owner).getContainingClass();
        if (importQName != null && containingClass != null) {
          return QualifiedName.fromDottedString(importQName + "." + containingClass.getName() + "." + name);
        }
      }
      else if (owner instanceof PyFile) {
        if (builtinCache.isBuiltin(element)) {
          return QualifiedName.fromDottedString(name);
        }
        else {
          final VirtualFile virtualFile = ((PyFile)owner).getVirtualFile();
          if (virtualFile != null) {
            final QualifiedName fileQName = QualifiedNameFinder.findCanonicalImportPath(element, element);
            if (fileQName != null) {
              return QualifiedName.fromDottedString(fileQName + "." + name);
            }
          }
        }
      }
      else {
        if (element instanceof PyFile) {
          return QualifiedNameFinder.findCanonicalImportPath(element, element);
        }
      }
    }
    return null;
  }


ullable
  public static QualifiedName getFullQualifiedName(@Nullable final PsiElement element) {