def get_single_key(d):
    """Get a key from a dict which contains just one item."""
    assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
    return next(six.iterkeys(d))
Get a key from a dict which contains just one item.