JsonValueAdapter (@NotNull JsonLikePsiWalker walker, @NotNull PsiElement element) { final Ref<PsiElement> ref = new Ref<>(); PsiTreeUtil.findFirstParent(element, el -> { final boolean isTop = walker.isTopJsonElement(el); if (!isTop) ref.set(el); return isTop; }); return ref.isNull() ? (walker.acceptsEmptyRoot() ? walker.createValueAdapter(element) : null) : walker.createValueAdapter(ref.get()); }