private void parseDictOrSetTail(@NotNull SyntaxTreeBuilder.Marker expr, boolean isDict) {
    final SyntaxTreeBuilder.Marker firstExprMarker = myBuilder.mark();

    if (isDict && !parseSingleExpression(false) || !isDict && !parseNamedTestExpression(false, false)) {
      myBuilder.error(message("PARSE.expected.expression"));
      firstExprMarker.drop();
      expr.done(PyElementTypes.DICT_LITERAL_EXPRESSION);
      return;
    }

    if (matchToken(PyTokenTypes.COLON)) {
      if (!isDict) {
        firstExprMarker.rollbackTo();
        parseDictOrSetTail(expr, true);
        return;
      }
      parseDictLiteralTail(expr, firstExprMarker);
    }
    else if (atToken(PyTokenTypes.COMMA) || atToken(PyTokenTypes.RBRACE)) {
      firstExprMarker.drop();
      parseSetLiteralTail(expr);
    }
    else if (atForOrAsyncFor()) {
      firstExprMarker.drop();
      parseComprehension(expr, PyTokenTypes.RBRACE, PyElementTypes.SET_COMP_EXPRESSION);
    }
    else {
      myBuilder.error(message("PARSE.expected.expression"));
      firstExprMarker.drop();
      expr.done(PyElementTypes.DICT_LITERAL_EXPRESSION);
    }
  }
private void parseDictOrSetTail(@NotNull SyntaxTreeBuilder.Marker expr, boolean isDict)