def write_groups_to_hdf5( group, name, value ):

    global str_dtype

    filename = group.file.filename

    if isinstance(value,dict):
        dict_grp = create_group(group, name)
        dict_grp = group.create_group(name)
        for k, v in value.items():
            write_groups_to_hdf5( dict_grp, k, v )
    elif isinstance( value, VariableTree): # TODO
        vartree_grp = create_group(group, name)
        vartree_grp = group.create_group(name)
        vartree_grp.attrs['__vartree__'] = True # to indicate this is a var tree
        for k in value.list_vars():
            write_groups_to_hdf5( vartree_grp, k, value.get(k) )
    elif isinstance( value, np.ndarray):
        if group.file.driver == 'mpio': # cannot do compression when writing in parallel
            create_dataset(group, name, data=value)
            if value.shape == (0,) :
                group.create_dataset(name, data=value, maxshape=(1,)) # h5py does not like completely empty arrays
            else:
                group.create_dataset(name, data=value)
        else:
            create_dataset(group, name, data=value, compression='gzip', chunks=True)
            group.create_dataset(name, data=value, compression='gzip', chunks=True)
    elif isinstance( value, list):
        if len( value ) > 0:
            if isinstance( value[0], str):
                create_dataset(group, name, (len(value),),str_dtype ) # TODO check to make sure it fits
                group.create_dataset(name, (len(value),),str_dtype ) # TODO check to make sure it fits
        else:
            create_dataset(group, name,(0,)) # TODO How do we handle empty lists? Do not know type
            group.create_dataset(name,(0,)) # TODO How do we handle empty lists? Do not know type
    elif value == None : # TODO Need a better way to do this. When using h5diff, we get 'Not comparable' with these values
        create_dataset(group, name,(0,)) # TODO: This results in DATATYPE  H5T_IEEE_F32LE  DATASPACE  SIMPLE { ( 0 ) / ( 0 ) }
        group.create_dataset(name,(0,)) # TODO: This results in DATATYPE  H5T_IEEE_F32LE  DATASPACE  SIMPLE { ( 0 ) / ( 0 ) }
    elif isinstance( value, (np.float64,float)):
        create_dataset(group, name, (), dtype=np.float64)
        group.create_dataset(name, (), dtype=np.float64)
    elif isinstance(value,int):
        create_dataset(group, name, (), dtype=np.int64)
        group.create_dataset(name, (), dtype=np.int64)
    elif isinstance(value,str):
        dset = create_dataset(group, name, (), dtype=str_dtype)
        dset = group.create_dataset(name, (), dtype=str_dtype)
    elif isinstance(value,bool):
        dset = create_dataset(group, name, (), dtype=np.bool)
        dset = group.create_dataset(name, (), dtype=np.bool)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/casehandlers/hdf5case.py/write_groups_to_hdf5/original