original_string: public function find($key, $type=null) {
          if ($type !== null && array_key_exists($type, $this->orderedcollection) && array_key_exists($key, $this->orderedcollection[$type])) {
              return $this->orderedcollection[$type][$key];
          } else {
              $nodes = $this->getIterator();
              // Search immediate children first
              foreach ($nodes as &$node) {
                  if ($node->key === $key && ($type === null || $type === $node->type)) {
                      return $node;
                  }
              }
              // Now search each childs children
              foreach ($nodes as &$node) {
                  $result = $node->children->find($key, $type);
                  if ($result !== false) {
                      return $result;
                  }
              }
          }
          return false;
      }
code: public function find($key, $type=null) {
          if ($type !== null && array_key_exists($type, $this->orderedcollection) && array_key_exists($key, $this->orderedcollection[$type])) {
              return $this->orderedcollection[$type][$key];
          } else {
              $nodes = $this->getIterator();
              // Search immediate children first
              foreach ($nodes as &$node) {
                  if ($node->key === $key && ($type === null || $type === $node->type)) {
                      return $node;
                  }
              }
              // Now search each childs children
              foreach ($nodes as &$node) {
                  $result = $node->children->find($key, $type);
                  if ($result !== false) {
                      return $result;
                  }
              }
          }
          return false;
      }
code_tokens: public function find ( $ key , $ type = null ) { if ( $ type !== null && array_key_exists ( $ type , $ this -> orderedcollection ) && array_key_exists ( $ key , $ this -> orderedcollection [ $ type ] ) ) { return $ this -> orderedcollection [ $ type ] [ $ key ] ; } else { $ nodes = $ this -> getIterator ( ) ; // Search immediate children first foreach ( $ nodes as & $ node ) { if ( $ node -> key === $ key && ( $ type === null || $ type === $ node -> type ) ) { return $ node ; } } // Now search each childs children foreach ( $ nodes as & $ node ) { $ result = $ node -> children -> find ( $ key , $ type ) ; if ( $ result !== false ) { return $ result ; } } } return false ; }
docstring: Searches for a node with matching key and type.
  
  This function searches both the nodes in this collection and all of
  the nodes in each collection belonging to the nodes in this collection.
  
  Recursive.
  
  @param string|int $key  The key of the node we want to find.
  @param int $type  One of navigation_node::TYPE_*.
  @return navigation_node|null
docstring_tokens: Searches for a node with matching key and type .