public function treeByDepth(Map\Request\TreeByDepth $req)
 {
     $result = new Response\TreeByDepth();
     /* extract parameters from request */
     $keyCustId = $req->getAsCustomerId();
     $keyDepth = $req->getAsDepth();
     $toMap = $req->getDataToMap();
     $shouldReversed = $req->getShouldReversed();
     $mapped = [];
     foreach ($toMap as $item) {
         $customerId = $item[$keyCustId];
         $depth = $item[$keyDepth];
         if (!isset($mapped[$depth])) {
             $mapped[$depth] = [];
         }
         $mapped[$depth][] = $customerId;
     }
     if ($shouldReversed) {
         krsort($mapped);
     }
     $result->setMapped($mapped);
     $result->markSucceed();
     return $result;
 }
 private function _mapByTreeDepthDesc($tree)
 {
     $req = new DownlineMapTreeByDepthRequest();
     $req->setDataToMap($tree);
     $req->setAsCustomerId(Compress::ATTR_CUSTOMER_ID);
     $req->setAsDepth(Snap::ATTR_DEPTH);
     $req->setShouldReversed(true);
     $resp = $this->_callDownlineMap->treeByDepth($req);
     return $resp->getMapped();
 }