Service/CategoryService.php
protected function findPartialTree($tree, $categoryId)
    {
        /** @var AbstractCategoryDocument $node */
        foreach ($tree as $node) {
            if ($node->getId() == $categoryId) {
                return [$node];
            }
            if ($node->getChildren()) {
                $result = $this->findPartialTree($node->getChildren(), $categoryId);
                if (!empty($result)) {
                    return $result;
                }
            }
        }

        return [];
    }
protected function findPartialTree($tree, $categoryId)
    {
        /** @var AbstractCategoryDocument $node */
        foreach ($tree as $node) {
            if ($node->getId() == $categoryId) {
                return [$node];
            }
            if ($node->getChildren()) {
                $result = $this->findPartialTree($node->getChildren(), $categoryId);
                if (!empty($result)) {
                    return $result;
                }
            }
        }

        return [];
    }
protected function findPartialTree ( $ tree , $ categoryId ) { /** @var AbstractCategoryDocument $node */ foreach ( $ tree as $ node ) { if ( $ node -> getId ( ) == $ categoryId ) { return [ $ node ] ; } if ( $ node -> getChildren ( ) ) { $ result = $ this -> findPartialTree ( $ node -> getChildren ( ) , $ categoryId ) ; if ( ! empty ( $ result ) ) { return $ result ; } } } return [ ] ; }
Returns partial tree by category ID.

@param array|\ArrayIterator $tree
@param string               $categoryId

@return array
Returns partial tree by category ID .