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 [];
    }