Write query result directly to response handle. Also changing tree_id paramater to tree.