<p>I have a dict, that looks like this:</p>

<pre><code>{
    'foo': {
        'opt1': 1,
        'opt2': 2,
        },
    'foo/bar': {
        'opt3': 3,
        'opt4': 4,
        },
    'foo/bar/baz': {
        'opt5': 5,
        'opt6': 6,
        }
    }
</code></pre>

<p>And I need to get it to look like:</p>

<pre><code>{
    'foo': {
        'opt1': 1,
        'opt2': 2,
        'bar': {
            'opt3': 3,
            'opt4': 4,
            'baz': {
                'opt5': 5,
                'opt6': 6,
                }
            }
        }
    }
</code></pre>

<p>I should point out that there can and will be multiple top-level keys ('foo' in this case). I could probably throw something together to get what i need, but I was hoping that there is a solution that's more efficient.</p>

Like this:
```
```
def nest(d):
    rv = {}
    for key, value in d.iteritems():
        node = rv
        for part in key.split('/'):
            node = node.setdefault(part, {})
        node.update(value)
    return rv
```
```