def create_group(current, name, attrs, overwrite):
    """
    Create and HDF5 group from the current level.

    Parameters:
    ===========
    - current:    h5py Group or File object
                  The current level

    - name:       string
                  The name of the new group

    - attrs:      dictionary
                  attributes to assign to the group

    - overwrite:  boolean
                  If True and the name is already a group in the current level,
                  overwrite it. Otherwise, just return that group.

    Returns:
    An h5py Group object.
    """
    if name in current:
        if not overwrite:
            return current[name]

        # Update the attributes
        for k in attrs:
            current[name].attrs[k] = attrs[k]
        return current[name]

    group = current.create_group(name)
    for k in attrs:
        group.attrs[k] = attrs[k]
    return group