Refactor AST to generalize base terms and binders