protected function _markUnrelatedAsHidden(&$tree, array $path, $level = 0)
    {
        extract($this->_config);
        $siblingIsActive = false;
        foreach ($tree as $key => &$subTree) {
            if (is_object($subTree)) {
                $subTree = $subTree->toArray();
            }
            if (!isset($subTree['children'])) {
                throw new Exception('Only works with threaded (nested children) results');
            }

            if (!empty($path[$level]) && $subTree['id'] == $path[$level]['id']) {
                $subTree['show'] = 1;
                $siblingIsActive = true;
            }
            if (!empty($subTree['show'])) {
                foreach ($subTree['children'] as &$v) {
                    $v['parent_show'] = 1;
                }
            }
            if (is_numeric($hideUnrelated) && $hideUnrelated > $level) {
                $siblingIsActive = true;
            }
        }
        foreach ($tree as $key => &$subTree) {
            if ($level && !$siblingIsActive && !isset($subTree['parent_show'])) {
                $subTree['hide'] = 1;
            }
            $this->_markUnrelatedAsHidden($subTree['children'], $path, $level + 1);
        }
    }