private static <T extends PsiElement> T getParentClassOrObject(
            @NotNull PsiElement element,
            @NotNull java.lang.Class<? extends T> klass
    ) {
        PsiElement e = element;
        while (e != null && !klass.isInstance(e)) {
            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) {
                return null;
            }
            e = e.getParent();
        }

        //noinspection unchecked
        return (T) e;
    }
private static <T extends PsiElement> T getParentClassOrObject(
            @NotNull PsiElement element,
            @NotNull java.lang.Class<? extends T> klass
    )