Optimizing Query Routing Trees in Wireless Sensor Networks