List of parent and child into nested dictionary
<p>I have a list that I'd like to transform into a nested dictionary. The first element of the list is the parent, the second the child. Can I do this recursively without having to continue creating helper lists for each level? I feel so dumb not understanding this.</p>

<pre><code>relations = [["basket", "money"],
             ["basket", "fruits"],
             ["fruits", "orange"],
             ["fruits", "apple"],
             ["basket", "vegetables"],
             ["vegetables", "bean"],
             ["vegetables", "tomato"],
             ["tomato", "red tomato"],
             ["tomato", "green tomato"],
             ["vegetables", "pepper"],
             ["sweets", "candy"]]


result = {}
running_list = []

for parent, child in relations:
    if parent == "basket":
        result[child] = {}
        running_list.append(child)

for parent, child in relations:
    if parent in running_list:
        result[parent] = {child : {}}

print result
</code></pre>