Antrl: Walking through if/elseif/else javascript

I know there a lot about this problem but I can't find the solution to my problem. So any help will be much appreciated.

I'm trying to parse js file with antrl into java. I'm using the lexer and parser g4 files from antl-github


Then I use JavaScriptListener for parsing. The problem I faced is the nested construction of if/else blocks. For example, I have the following js code:

if (if_1) {
    if (nested_if_1) {
} else if (else_if_1) {
    else_if_1_a = else_if_1_b;

Here problem is how to find out the else if to which if blocks belongs? Or how can I figure it out that second if it is inside the first one?

As listener has only two methods related to if:

enterIfStatement(JavaScriptParser.IfStatementContext ctx)

exitIfStatement(JavaScriptParser.IfStatementContext ctx)