Sometimes the data in your SQL database represents hierarchical data. For example, a bill of materials, departments, or reporting structures (employee directory).
You may not know it, but you can actually do fully recursive queries directly in SQL using common table expressions (CTEs). I wrote up a github 'gist' including example data and SQL code to demonstrate how to do this.
Check it out here on github