boolean (@NotNull PsiElement element) { PsiElement e = element; while (e != null) { if (e instanceof KtModifierList) { // skip property/function/class or object which is owner of modifier list e = e.getParent(); if (e != null) { e = e.getParent(); } continue; } if (e instanceof KtProperty || e instanceof KtNamedFunction || e instanceof KtClassOrObject) { return false; } if (e instanceof KtScriptInitializer) { return false; } e = e.getParent(); } return true; }