PyBinaryExpression (String s, PyExpression expr, PyExpression listLiteral) { final PsiFile dummyFile = createDummyFile(LanguageLevel.getDefault(), "a " + s + " b"); final PyExpressionStatement expressionStatement = (PyExpressionStatement)dummyFile.getFirstChild(); PyBinaryExpression binExpr = (PyBinaryExpression)expressionStatement.getExpression(); ASTNode binnode = binExpr.getNode(); binnode.replaceChild(binExpr.getLeftExpression().getNode(), expr.getNode().copyElement()); binnode.replaceChild(binExpr.getRightExpression().getNode(), listLiteral.getNode().copyElement()); return binExpr; }