void (@Nullable PsiElement lastElementOrOpeningBrace) { PsiElement element = lastElementOrOpeningBrace != null ? lastElementOrOpeningBrace.getNextSibling() : null; while (element != null) { if (element.getNode().getElementType() == JsonElementTypes.COMMA || element instanceof PsiErrorElement && ",".equals(element.getText())) { deleteNode(element.getNode()); } else if (!(element instanceof PsiComment || element instanceof PsiWhiteSpace)) { break; } element = element.getNextSibling(); } }