Programatically creating a nested taxonomy list in Drupal 7
Say you have a taxonomy hierarchy in which you would like to create a nested list. While it is possible to loop through a taxonomy tree and create the html markup using a number of conditional statements, this is far from ideal and prone to error. I much prefer to use Drupal's theme functions whenever possible to generate html from a render array. In this demonstration, we'll grab all taxonomy terms in a vocabulary and use some recursion to construct manageable data structures that we can then leave to Drupal to generate all the html.