title: How to recursively sum-up the leaves node of a nested tree dictionary in python?
body: <p>As shown in the example below, I would like to recursively find the leaves nodes, then calculate the sum of those leaves node. If the sum is greater than some threshold, then delete those leaves node, otherwise ignore it and move on to the next set of leaves node.</p>
  <pre><code>tree= {'Age': {'&gt; 55': 0.4, '&lt; 18': {'Income': {'high': 0, 'low': 0.2}}, 
                 '18-35': 0.25, '36-55': {'Marital_Status': {'single': {'Income': 
                 {'high': 0, 'low': 0.1}}, 'married': 0.05}}}}
  </code></pre>
  <p>For example, first Income node has two leaves (0,0.2) with a sum of 0.2. I would like to delete these leaves nodes since sum is greater than the threshold
  Another example, second income node has two leaves (0, 0.1) with a sum of 0.1, I would like to ignore it since sum is less than threshold</p>