Fixed code to traverse the AST instead of the parse tree