walkForEachAST method switch statement instead of if statement