title: Rails helper method: Nested hash to nested HTML list
body: <p>I am trying to write a Rails helper method to convert a nested hash into a nested HTML list.</p>
  
  <p>For example:</p>
  
  <pre><code>{
    :parent =&gt; "foo",
    :children =&gt; [
      {
        :parent =&gt; "bar",
        :children =&gt; [
          {
            :parent =&gt; "baz",
            :children =&gt; []
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>should become:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li&gt;foo&lt;/li&gt;
    &lt;ul&gt;
      &lt;li&gt;bar&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;baz&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>The hash may have any number of levels, and any number of parents per level.</p>
  
  <p>What is the best way to achieve this please?</p>