# How jq recurse Works for Tree Traversal: Implementation Guide

> Learn how jq recurse performs depth-first tree traversal using a self-referential helper function implemented entirely in jq's scripting language. Master jq tree traversal.

- Repository: [jqlang/jq](https://github.com/jqlang/jq)
- Tags: internals
- Published: 2026-04-11

---

**The `jq recurse` filter performs depth-first tree traversal by defining a self-referential helper function that yields the current node then recursively descends through user-specified children, implemented entirely in jq's own scripting language within `src/builtin.jq`.**

The `recurse` filter is one of jq's most powerful built-ins for navigating nested JSON structures. Unlike many core functions implemented in C, `recurse` lives as a native jq definition in the jqlang/jq repository, demonstrating the language's ability to express complex recursive algorithms using closures and self