/**
  * @param Account $account
  * @return null|PriceList
  */
 protected function getPriceListFromAccountGroupTree(Account $account)
 {
     $parentAccount = $account->getParent();
     if (!$parentAccount) {
         return null;
     }
     while ($parentAccount) {
         $parentGroup = $parentAccount->getGroup();
         if ($parentGroup) {
             $priceList = $this->getPriceListRepository()->getPriceListByAccountGroup($parentGroup);
             if ($priceList) {
                 return $priceList;
             }
         }
         $parentAccount = $parentAccount->getParent();
     }
     return null;
 }
 /**
  * @param Account $entity
  * @param int $rootId
  * @return array
  */
 protected function formatEntity(Account $entity, $rootId)
 {
     return ['id' => $entity->getId(), 'parent' => $entity->getParent() && $entity->getParent()->getId() !== $rootId ? $entity->getParent()->getId() : '#', 'text' => $entity->getName(), 'state' => ['opened' => !$entity->getChildren()->isEmpty()]];
 }