def dataverse_tree_walker(
    data: list,
    dv_keys: list = ["dataverse_id", "dataverse_alias"],
    ds_keys: list = ["dataset_id", "pid"],
    df_keys: list = ["datafile_id", "filename", "pid", "label"],
) -> tuple:
    """Walk through a Dataverse tree by get_children().

    Recursively walk through the tree structure returned by ``get_children()``
    and extract the keys needed.

    Parameters
    ----------
    data : dict
        Tree data structure returned by ``get_children()``.
    dv_keys : list
        List of keys to be extracted from each Dataverse element.
    ds_keys : list
        List of keys to be extracted from each Dataset element.
    df_keys : list
        List of keys to be extracted from each Datafile element.

    Returns
    -------
    tuple
        (List of Dataverse, List of Datasets, List of Datafiles)
    """
    dataverses = []
    datasets = []
    datafiles = []

    if type(data) == list:
        for elem in data:
            dv, ds, df = dataverse_tree_walker(elem)
            dataverses += dv
            datasets += ds
            datafiles += df
    elif type(data) == dict:
        if data["type"] == "dataverse":
            dv_tmp = {}
            for key in dv_keys:
                if key in data:
                    dv_tmp[key] = data[key]
            dataverses.append(dv_tmp)
        elif data["type"] == "dataset":
            ds_tmp = {}
            for key in ds_keys:
                if key in data:
                    ds_tmp[key] = data[key]
            datasets.append(ds_tmp)
        elif data["type"] == "datafile":
            df_tmp = {}
            for key in df_keys:
                if key in data:
                    df_tmp[key] = data[key]
            datafiles.append(df_tmp)
        if "children" in data:
            if len(data["children"]) > 0:
                dv, ds, df = dataverse_tree_walker(data["children"])
                dataverses += dv
                datasets += ds
                datafiles += df
    return dataverses, datasets, datafiles