title: How to find the depth of a dictionary that contains a list of dictionaries?
body: <p>I would like to know the depth of a dict that contains a list of dicts, I wrote a simple code but the problem is that it increment the counter of depth at each step.</p>
  <p>this is the input that i have as an example :</p>
  <pre><code>respons = {
      &quot;root&quot;:{
          &quot;Flow&quot;:[{
              &quot;Name&quot;:&quot;BSB1&quot;,
              &quot;Output&quot;:[{
                  &quot;Name&quot;:&quot;BSB2&quot;,
                  &quot;Output&quot;:[{
                      &quot;Name&quot;:&quot;BSB5&quot;,
                      &quot;Output&quot;:[{
                          &quot;Name&quot;:&quot;BSB6&quot;,
                          &quot;Output&quot;:[{
                              &quot;Name&quot;:&quot;BSB8&quot;,
                              &quot;Output&quot;:[]
                          }]
                      },
                      {
                          &quot;Name&quot;:&quot;BSB7&quot;,
                          &quot;Output&quot;:[]
                      }]
                  }]
              },
              {
                  &quot;Name&quot;:&quot;BSB3&quot;,
                  &quot;Output&quot;:[{
                      &quot;Name&quot;:&quot;BSB4&quot;,
                      &quot;Output&quot;:[]
                  }]
              }]
          }]
      }
  }
  
  </code></pre>
  <pre><code>def calculate_depth(flow,depth):
      depth+=1
      md = []
      if flow['Output']:
          for o in flow['Output']:
              print(o['BusinessUnit'])
              md.append(calculate_depth(o,depth))
          print(max(md))
          print(md)
          return max(md)
      else:
          return depth
          
  
  print(calculate_depth(respons['root']['Flow'][0],0))
  
  
  </code></pre>
  <p>normally I want the depth of the longest branch of this dict not to go through all of the branches and increment at each step</p>
  <h2>EDIT</h2>
  <p>The desired Outcome will be for this structure : 5
  Why ?
  It is the longest branche BSB1 =&gt; BSB2 =&gt; BSB5 =&gt; BSB6 =&gt; BSB8</p>