public function filter(callable $fn) { $nodes = []; foreach ($this->nodes as $i => $n) { $cx = $this->newContext($n); $ret = $this->callfn($fn, [$cx, $i, $n]); if ($ret !== false) { $nodes[] = $n; } } return $this->newContext($nodes); }