docs: private void handleLastDataPointQuery(final TSDB tsdb, final HttpQuery query) {
      
      final LastPointQuery data_query;
      if (query.method() == HttpMethod.POST) {
        switch (query.apiVersion()) {
        case 0:
        case 1:
          data_query = query.serializer().parseLastPointQueryV1();
          break;
        default: 
          throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED, 
              "Requested API version not implemented", "Version " + 
              query.apiVersion() + " is not implemented");
        }
      } else {
        data_query = this.parseLastPointQuery(tsdb, query);
      }
      
      if (data_query.sub_queries == null || data_query.sub_queries.isEmpty()) {
        throw new BadRequestException(HttpResponseStatus.BAD_REQUEST, 
            "Missing sub queries");
      }
      
      // a list of deferreds to wait on
      final ArrayList<Deferred<Object>> calls = new ArrayList<Deferred<Object>>();
      // final results for serialization
      final List<IncomingDataPoint> results = new ArrayList<IncomingDataPoint>();
      
      /**
       * Used to catch exceptions 
       */
      final class ErrBack implements Callback<Object, Exception> {
        public Object call(final Exception e) throws Exception {
          Throwable ex = e;
          while (ex.getClass().equals(DeferredGroupException.class)) {
            if (ex.getCause() == null) {
              LOG.warn("Unable to get to the root cause of the DGE");
              break;
            }
            ex = ex.getCause();
          }
          if (ex instanceof RuntimeException) {
            throw new BadRequestException(ex);
          } else {
            throw e;
          }
        }
        @Override
        public String toString() {
          return "Error back";
        }
      }
      
      final class FetchCB implements Callback<Deferred<Object>, ArrayList<IncomingDataPoint>> {
        @Override
        public Deferred<Object> call(final ArrayList<IncomingDataPoint> dps) throws Exception {
          synchronized(results) {
            for (final IncomingDataPoint dp : dps) {
              if (dp != null) {
                results.add(dp);
              }
            }
          }
          return Deferred.fromResult(null);
        }
        @Override
        public String toString() {
          return "Fetched data points CB";
        }
      }
      
      /**
       * Called after scanning the tsdb-meta table for TSUIDs that match the given
       * metric and/or tags. If matches were found, it fires off a number of
       * getLastPoint requests, adding the deferreds to the calls list
       */
      final class TSUIDQueryCB implements Callback<Deferred<Object>, ByteMap<Long>> {
        public Deferred<Object> call(final ByteMap<Long> tsuids) throws Exception {
          if (tsuids == null || tsuids.isEmpty()) {
            return null;
          }
          final ArrayList<Deferred<IncomingDataPoint>> deferreds =
              new ArrayList<Deferred<IncomingDataPoint>>(tsuids.size());
          for (Map.Entry<byte[], Long> entry : tsuids.entrySet()) {
            deferreds.add(TSUIDQuery.getLastPoint(tsdb, entry.getKey(), 
                data_query.getResolveNames(), data_query.getBackScan(), 
                entry.getValue()));
          }
          return Deferred.group(deferreds).addCallbackDeferring(new FetchCB());
        }
        @Override
        public String toString() {
          return "TSMeta scan CB";
        }
      }
  
      /**
       * Used to wait on the list of data point deferreds. Once they're all done
       * this will return the results to the call via the serializer
       */
      final class FinalCB implements Callback<Object, ArrayList<Object>> {
        public Object call(final ArrayList<Object> done) throws Exception {
          query.sendReply(query.serializer().formatLastPointQueryV1(results));
          return null;
        }
        @Override
        public String toString() {
          return "Final CB";
        }
      }
      
      try {   
        // start executing the queries
        for (final LastPointSubQuery sub_query : data_query.getQueries()) {
          final ArrayList<Deferred<IncomingDataPoint>> deferreds =
              new ArrayList<Deferred<IncomingDataPoint>>();
          // TSUID queries take precedence so if there are any TSUIDs listed, 
          // process the TSUIDs and ignore the metric/tags
          if (sub_query.getTSUIDs() != null && !sub_query.getTSUIDs().isEmpty()) {
            for (final String tsuid : sub_query.getTSUIDs()) {
              final TSUIDQuery tsuid_query = new TSUIDQuery(tsdb, 
                  UniqueId.stringToUid(tsuid));
              deferreds.add(tsuid_query.getLastPoint(data_query.getResolveNames(), 
                  data_query.getBackScan()));
            }
          } else {
            @SuppressWarnings("unchecked")
            final TSUIDQuery tsuid_query = 
                new TSUIDQuery(tsdb, sub_query.getMetric(), 
                    sub_query.getTags() != null ? 
                        sub_query.getTags() : Collections.EMPTY_MAP);
            if (data_query.getBackScan() > 0) {
              deferreds.add(tsuid_query.getLastPoint(data_query.getResolveNames(), 
                  data_query.getBackScan()));
            } else {
              calls.add(tsuid_query.getLastWriteTimes()
                  .addCallbackDeferring(new TSUIDQueryCB()));
            }
          }
          
          if (deferreds.size() > 0) {
            calls.add(Deferred.group(deferreds).addCallbackDeferring(new FetchCB()));
          }
        }
        
        Deferred.group(calls)
          .addCallback(new FinalCB())
          .addErrback(new ErrBack())
          .joinUninterruptibly();
        
      } catch (Exception e) {
        Throwable ex = e;
        while (ex.getClass().equals(DeferredGroupException.class)) {
          if (ex.getCause() == null) {
            LOG.warn("Unable to get to the root cause of the DGE");
            break;
          }
          ex = ex.getCause();
        }
        if (ex instanceof RuntimeException) {
          throw new BadRequestException(ex);
        } else {
          throw new RuntimeException("Shouldn't be here", e);
        }
      }
    }