public function closest(callable $callback) {
    $matches = [];
    foreach ($this->nodes as $node) {
      if ($match = $node->closest($callback)) {
        $matches[] = $match;
      }
    }
    return new NodeCollection($matches);
  }
public function closest(callable $callback) {
    $matches = [];
    foreach ($this->nodes as $node) {
      if ($match = $node->closest($callback)) {
        $matches[] = $match;
      }
    }
    return new NodeCollection($matches);
  }
public function closest ( callable $ callback ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { if ( $ match = $ node -> closest ( $ callback ) ) { $ matches [ ] = $ match ; } } return new NodeCollection ( $ matches ) ; }
For each node in the collection, get the first node matched by the
callback by testing this node and traversing up through its ancestors in
the tree.
@param callable $callback Callback to test for match.
@return Node
For each node in the collection get the first node matched by the callback by testing this node and traversing up through its ancestors in the tree .