Use array_unshift() instead of direct access for getting first value.

If passing an array containing a single geometry keyed by something other than 0 count will return 1 but the recursive call to geometryReduce will receive NULL.