private void visitIf(IfStatementTree tree) {
    scan(tree.condition());
    scan(tree.statement());

    ElseClauseTree elseClauseTree = tree.elseClause();
    if (tree.elseClause() != null && elseClauseTree.statement().is(Kind.IF_STATEMENT)) {
      visitIf((IfStatementTreeImpl) tree.elseClause().statement());

    } else {
      scan(tree.elseClause());
    }
  }
  @Test
  public void with_else() throws Exception {
    IfStatementTree tree = parse("if (a) {} else {}", Kind.IF_STATEMENT);

    assertThat(tree.is(Kind.IF_STATEMENT)).isTrue();
    assertThat(tree.ifKeyword().text()).isEqualTo(JavaScriptKeyword.IF.getValue());
    assertThat(tree.openParenthesis().text())
        .isEqualTo(JavaScriptPunctuator.LPARENTHESIS.getValue());
    assertThat(tree.condition()).isNotNull();
    assertThat(tree.closeParenthesis().text())
        .isEqualTo(JavaScriptPunctuator.RPARENTHESIS.getValue());
    assertThat(tree.statement().is(Kind.BLOCK)).isTrue();

    assertThat(tree.elseClause().elseKeyword().text()).isEqualTo(JavaScriptKeyword.ELSE.getValue());
    assertThat(tree.elseClause().statement().is(Kind.BLOCK)).isTrue();
  }