boolean (@NotNull PsiElement element) { return SyntaxTraverser.psiApi() .parents(element) .takeWhile(e -> !(e instanceof PsiExpression)) .find(e -> e instanceof PsiImportStatementBase || e instanceof PsiPackageStatement) != null; }