boolean (@NotNull T literal, int index) { int currentIndex = 0; PsiElement each = literal; while (each != null) { each = each.getPrevSibling(); if (each instanceof PsiExpression) { currentIndex++; if (currentIndex > index) return false; } } if (currentIndex != index) return false; return true; }