<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_hdf5_dict(flags, output, path=None, append=False, overwrite=False, **kwargs):
 """Write this `DataQualityFlag` to a `h5py.Group`. This allows writing to an HDF5-format file. Parameters output : `str`, :class:`h5py.Group` path to new output file, or open h5py `Group` to write to. path : `str` the HDF5 group path in which to write a new group for this flag **kwargs other keyword arguments passed to :meth:`h5py.Group.create_dataset` Returns ------- dqfgroup : :class:`h5py.Group` HDF group containing these data. This group contains 'active' and 'known' datasets, and metadata attrs. See also -------- astropy.io for details on acceptable keyword arguments when writing a :class:`~astropy.table.Table` to HDF5 """

    if path:
        try:
            parent = output[path]
        except KeyError:
            parent = output.create_group(path)
    else:
        parent = output

    for name in flags:
        # handle existing group
        if name in parent:
            if not (overwrite and append):
                raise IOError("Group '%s' already exists, give ``append=True, "
                              "overwrite=True`` to overwrite it"
                              % os.path.join(parent.name, name))
            del parent[name]
        # create group
        group = parent.create_group(name)
        # write flag
        write_hdf5_flag_group(flags[name], group, **kwargs)