public function filterRange($range)
    {
        if (is_int($range)) {
            $level = $range;
            $depth = 0;
        } else {
            reset($range);
            $level = key($range);
            $depth = current($range);
        }

        if (1 === $level) {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.'  ]')->item(0);
        } else {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.' and ( descendant-or-self::*[ contains(@class, "open") or contains(@class, "active") ] or ancestor-or-self::*[ contains(@class, "open")  or contains(@class, "active") ] ) ]')->item(0);
        }

        if (!$nodeList) {
            return false;
        }

        if (false === $depth) {
            return $nodeList;
        }

        $depthNodelist = $this->xp->query('./descendant::*[ name() = "ul" and count( ancestor-or-self::ul ) > '.($level + $depth).' ]', $nodeList);

        foreach ($depthNodelist as $node) {
            $node->parentNode->removeChild($node);
        }

        if ($nodeList) {
            return $nodeList;
        } else {
            return false;
        }
    }
public function filterRange($range)
    {
        if (is_int($range)) {
            $level = $range;
            $depth = 0;
        } else {
            reset($range);
            $level = key($range);
            $depth = current($range);
        }

        if (1 === $level) {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.'  ]')->item(0);
        } else {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.' and ( descendant-or-self::*[ contains(@class, "open") or contains(@class, "active") ] or ancestor-or-self::*[ contains(@class, "open")  or contains(@class, "active") ] ) ]')->item(0);
        }

        if (!$nodeList) {
            return false;
        }

        if (false === $depth) {
            return $nodeList;
        }

        $depthNodelist = $this->xp->query('./descendant::*[ name() = "ul" and count( ancestor-or-self::ul ) > '.($level + $depth).' ]', $nodeList);

        foreach ($depthNodelist as $node) {
            $node->parentNode->removeChild($node);
        }

        if ($nodeList) {
            return $nodeList;
        } else {
            return false;
        }
    }
public function filterRange ( $ range ) { if ( is_int ( $ range ) ) { $ level = $ range ; $ depth = 0 ; } else { reset ( $ range ) ; $ level = key ( $ range ) ; $ depth = current ( $ range ) ; } if ( 1 === $ level ) { $ nodeList = $ this -> xp -> query ( '/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= ' . $ level . '  ]' ) -> item ( 0 ) ; } else { $ nodeList = $ this -> xp -> query ( '/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= ' . $ level . ' and ( descendant-or-self::*[ contains(@class, "open") or contains(@class, "active") ] or ancestor-or-self::*[ contains(@class, "open")  or contains(@class, "active") ] ) ]' ) -> item ( 0 ) ; } if ( ! $ nodeList ) { return false ; } if ( false === $ depth ) { return $ nodeList ; } $ depthNodelist = $ this -> xp -> query ( './descendant::*[ name() = "ul" and count( ancestor-or-self::ul ) > ' . ( $ level + $ depth ) . ' ]' , $ nodeList ) ; foreach ( $ depthNodelist as $ node ) { $ node -> parentNode -> removeChild ( $ node ) ; } if ( $ nodeList ) { return $ nodeList ; } else { return false ; } }
Restrict navigation to given range.

Examples:
$range = 3, only show level 3
$range = array( 1 => 0 ), only show level 1 and 0 nested levels

@param array $range

@return DOMNode $nodeList
Restrict navigation to given range .