lib/DTL/Glob/Finder/AbstractTraversalFinder.php
private function traverse(array $segments, &$result = array(), $node = null)
    {
        $path = array();

        if (null !== $node) {
            $path = explode('/', substr($node->getPath(), 1));
        }

        do {
            list($element, $bitmask) = array_shift($segments);

            if ($bitmask & SelectorParser::T_STATIC) {
                $path[] = $element;

                if ($bitmask & SelectorParser::T_LAST) {
                    if ($node = $this->getNode($path)) {
                        $result[] = $node;
                        break;
                    }
                }
            }

            if ($bitmask & SelectorParser::T_PATTERN) {
                if (null === $parentNode = $this->getNode($path)) {
                    return;
                }

                $children = $this->getChildren($parentNode, $element);

                foreach ($children as $child) {
                    if ($bitmask & SelectorParser::T_LAST) {
                        $result[] = $child;
                    } else {
                        $this->traverse($segments, $result, $child);
                    }
                }

                return;
            }
        } while ($segments);
    }
private function traverse(array $segments, &$result = array(), $node = null)
    {
        $path = array();

        if (null !== $node) {
            $path = explode('/', substr($node->getPath(), 1));
        }

        do {
            list($element, $bitmask) = array_shift($segments);

            if ($bitmask & SelectorParser::T_STATIC) {
                $path[] = $element;

                if ($bitmask & SelectorParser::T_LAST) {
                    if ($node = $this->getNode($path)) {
                        $result[] = $node;
                        break;
                    }
                }
            }

            if ($bitmask & SelectorParser::T_PATTERN) {
                if (null === $parentNode = $this->getNode($path)) {
                    return;
                }

                $children = $this->getChildren($parentNode, $element);

                foreach ($children as $child) {
                    if ($bitmask & SelectorParser::T_LAST) {
                        $result[] = $child;
                    } else {
                        $this->traverse($segments, $result, $child);
                    }
                }

                return;
            }
        } while ($segments);
    }
private function traverse ( array $ segments , & $ result = array ( ) , $ node = null ) { $ path = array ( ) ; if ( null !== $ node ) { $ path = explode ( '/' , substr ( $ node -> getPath ( ) , 1 ) ) ; } do { list ( $ element , $ bitmask ) = array_shift ( $ segments ) ; if ( $ bitmask & SelectorParser :: T_STATIC ) { $ path [ ] = $ element ; if ( $ bitmask & SelectorParser :: T_LAST ) { if ( $ node = $ this -> getNode ( $ path ) ) { $ result [ ] = $ node ; break ; } } } if ( $ bitmask & SelectorParser :: T_PATTERN ) { if ( null === $ parentNode = $ this -> getNode ( $ path ) ) { return ; } $ children = $ this -> getChildren ( $ parentNode , $ element ) ; foreach ( $ children as $ child ) { if ( $ bitmask & SelectorParser :: T_LAST ) { $ result [ ] = $ child ; } else { $ this -> traverse ( $ segments , $ result , $ child ) ; } } return ; } } while ( $ segments ) ; }
Traverse the node

@param NodeInterface|null $node  The node to traverse, if it exists yet
@param array $segments  The element => token stack
@param array $result  The result

@return null
Traverse the node