recursively transform an ast