code: protected function _initQuery()
      {
          $token = $this->getRequest()->getParam('token');
          $index = $this->getRequest()->getParam('index');
  
          if ($token === null || $index === null) {
              $this->getResponse()->setHttpResponseCode(400)->setBody('Invalid parameters');
              return null;
          }
  
          /** @var Sheep_Debug_Model_RequestInfo $requestProfile */
          $requestProfile = Mage::getModel('sheep_debug/requestInfo')->load($token, 'token');
          if (!$requestProfile->getId()) {
              $this->getResponse()->setHttpResponseCode(404)->setBody('Request profile not found');
              return null;
          }
  
          $queries = $requestProfile->getQueries();
          if (!$queries || !($index < count($queries))) {
              $this->getResponse()->setHttpResponseCode(404)->setBody('Query not found');
              return null;
          }
  
          /** @var Zend_Db_Profiler_Query $query */
          return $queries[(int)$index];
      }
docs: Returns query referenced in request parameters
  
  @return Sheep_Debug_Model_Query