def save_linear(file, tree):
    """
    Save tree leaves to an hdf5 file. Rather than nested directories
    following the tree layout, the tree is flattened to a linear
    array of leaves.

    Parameters
    ----------
    file: hdf5 group
        The hdf5 group to save the tree to.
    tree: ndtamr.Node
        The root of the tree to save

    """
    from json import dumps
    serial = {}
    for key, val in tree.args.items():
        try:
            serial[key] = val.__name__
        except AttributeError:
            serial[key] = val
    file.attrs['Pars'] = dumps(serial)
    for leaf in tree.list_leaves(attr='self'):
        leaf.save(file, full_name=True)
    return
