void (@NotNull PsiElement element, @NotNull String name, @Nullable String asName) { final PyElementGenerator generator = PyElementGenerator.getInstance(element.getProject()); final LanguageLevel languageLevel = LanguageLevel.forElement(element); final PsiElement anchor = getLocalInsertPosition(element); final PsiElement parentElement = sure(anchor).getParent(); if (parentElement != null) { parentElement.addBefore(generator.createImportStatement(languageLevel, name, asName), anchor); } }