Can I condense this for loop to a Collection using functional programming?

I have some code in my ANTLR project that looks like this:

ArrayList<MSSyntaxTree> procArgs = new ArrayList<>();
if (ctx.args() != null) {
    for (ParseTree pt : ctx.args().expr()) {

ArrayList<MSSyntaxTree> lambdaArgs = new ArrayList<>();
if (ctx.lambdaArgs() != null) {
    for (ParseTree pt : ctx.lambdaArgs().expr()) {

While this works, I’d like to not have to do a null check, iterate over the ParseTree objects, then add them to a list. Is there a way to do this all in one line with Java’s Collections API or its functional programming paradigms?


.strip not working on certain strings [python]

Create forms using Redux And React