def _create_required_groups(g, path):
    """
    Given a file or group handle, and a path, make sure that the specified
    path exists and create if necessary.
    """
    for dirname in path.split('/'):
        if not dirname in g:
            g = g.create_group(dirname)
        else:
            g = g[dirname]
