title: Python: recursively create dictionary from paths
body: <p>I have several hundred thousand endpoint URLs that I want to generate stats for.  For example I have:</p>
  <pre><code>/a/b/c
  /a/b/d
  /a/c/d
  /b/c/d
  /b/d/e
  /a/b/c
  /b/c/d
  </code></pre>
  <p>I want to create a dictionary that looks like this</p>
  <pre><code>{
      'a': {
          'b': {
              'c': {
                  '_count': 2
              },
              'd': {
                  '_count': 1
              }
          },
          'c': {
              'd': {
                  '_count': 1
              }
          }
      },
      'b': {
          'c': {
              'd': {
                  '_count': 2
              }
          },
          'd': {
              'e': {
                  '_count': 1
              }
          }
      }
  }
  </code></pre>
  <p>Any clever ways to do this?</p>
  <p><strong>EDIT</strong></p>
  <p>I should mention that the paths are not always 3 parts.  There might be
  <code>/a/b/c/d/e/f/g/h</code>... etc, etc.</p>