List<PyExpression> (PyExpression[] targets, List<PyExpression> receiver, boolean unfoldListLiterals, boolean unfoldStarExpressions) { // NOTE: this proliferation of instanceofs is not very beautiful. Maybe rewrite using a visitor. for (PyExpression exp : targets) { if (exp instanceof PyParenthesizedExpression parenExpr) { unfoldParentheses(new PyExpression[]{parenExpr.getContainedExpression()}, receiver, unfoldListLiterals, unfoldStarExpressions); } else if (exp instanceof PyTupleExpression tupleExpr) { unfoldParentheses(tupleExpr.getElements(), receiver, unfoldListLiterals, unfoldStarExpressions); } else if (exp instanceof PyListLiteralExpression listLiteral && unfoldListLiterals) { unfoldParentheses(listLiteral.getElements(), receiver, true, unfoldStarExpressions); } else if (exp instanceof PyStarExpression && unfoldStarExpressions) { unfoldParentheses(new PyExpression[]{((PyStarExpression)exp).getExpression()}, receiver, unfoldListLiterals, true); } else if (exp != null) { receiver.add(exp); } } return receiver; }