source/Application/Controller/Admin/NavigationTree.php
protected function _cleanEmptyParents($dom, $parentXPath, $childXPath)
    {
        $xPath = new DomXPath($dom);
        $nodeList = $xPath->query($parentXPath);

        foreach ($nodeList as $node) {
            $id = $node->getAttribute('id');
            $childList = $xPath->query("{$parentXPath}[@id='$id']/$childXPath");
            if (!$childList->length) {
                $node->parentNode->removeChild($node);
            }
        }
    }
protected function _cleanEmptyParents($dom, $parentXPath, $childXPath)
    {
        $xPath = new DomXPath($dom);
        $nodeList = $xPath->query($parentXPath);

        foreach ($nodeList as $node) {
            $id = $node->getAttribute('id');
            $childList = $xPath->query("{$parentXPath}[@id='$id']/$childXPath");
            if (!$childList->length) {
                $node->parentNode->removeChild($node);
            }
        }
    }
protected function _cleanEmptyParents ( $ dom , $ parentXPath , $ childXPath ) { $ xPath = new DomXPath ( $ dom ) ; $ nodeList = $ xPath -> query ( $ parentXPath ) ; foreach ( $ nodeList as $ node ) { $ id = $ node -> getAttribute ( 'id' ) ; $ childList = $ xPath -> query ( "{$parentXPath}[@id='$id']/$childXPath" ) ; if ( ! $ childList -> length ) { $ node -> parentNode -> removeChild ( $ node ) ; } } }
clean empty nodes from tree

@param object $dom         dom object
@param string $parentXPath parent xpath
@param string $childXPath  child xpath from parent
clean empty nodes from tree