hack: make joins work with unions despite mutability of AST nodes