void (@NotNull YAMLKeyValue key) { PsiElement anchor = null; for (PsiElement child = getLastChild(); child != null; child = child.getPrevSibling()) { final IElementType type = child.getNode().getElementType(); if (type == YAMLTokenTypes.COMMA || type == YAMLTokenTypes.LBRACE) { anchor = child; } } addAfter(key, anchor); final YAMLFile dummyFile = YAMLElementGenerator.getInstance(getProject()).createDummyYamlWithText("{,}"); final PsiElement comma = dummyFile.findElementAt(1); assert comma != null && comma.getNode().getElementType() == YAMLTokenTypes.COMMA; addAfter(comma, key); }