Refactor boolean traversal

Apply the visitor pattern to boolean expression traversal, as a start to reusable AST tools.
Refactor compile_boolean using it.