Understanding Optimal Data Gathering in the Energy and Latency Domains of a Wireless Sensor Network