public static void addImport(@NotNull PsiNamedElement target, @NotNull PsiFile file, @NotNull PyElement element) {
    if (target instanceof PsiFileSystemItem) {
      addFileSystemItemImport((PsiFileSystemItem)target, file, element);
      return;
    }

    final String name = target.getName();
    if (name == null) return;

    final PsiFileSystemItem toImport = target.getContainingFile();
    if (toImport == null) return;

    final QualifiedName importPath = QualifiedNameFinder.findCanonicalImportPath(target, element);
    if (importPath == null) return;

    final String path = importPath.toString();
    final ImportPriority priority = getImportPriority(file, toImport);
    if (!PyCodeInsightSettings.getInstance().PREFER_FROM_IMPORT) {
      addImportStatement(file, path, null, priority, element);

      final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(file.getProject());
      element.replace(elementGenerator.createExpressionFromText(LanguageLevel.forElement(target), path + "." + name));
    }
    else {
      addOrUpdateFromImportStatement(file, path, name, null, priority, element);
    }
  }
public static void addImport(@NotNull PsiNamedElement target, @NotNull PsiFile file, @NotNull PyElement element)