--- title: Moonwalk::moonwalk --- Moonwalk::moonwalk — Output generator for walking up the DOM tree ## Description ##
public Moonwalk::moonwalk ( \Closure|null $filter = null ) : \Generator
Non-standard. Creates a [`\Generator`](https://www.php.net/manual/en/class.generator.php) object for walking up the DOM tree. This is in lieu of recreating the awful [DOM TreeWalker API](https://developer.mozilla.org/en-US/docs/Web/API/Treewalker).
## Examples ##
**Example \#1 Print name of all ancestors of the H1 element**
```php
loadHTML('