def list_flat_branches(filename, treename, use_dtype=True):
    import root_numpy
    import numpy
    result = []
    data = root_numpy.root2array(filename, treename=treename, stop=1)
    for branch, value in data.dtype.fields.items():
        if use_dtype:
            if value[0].name != 'object':
                result.append(branch)
            else:
                matrix = numpy.array(list(data[branch]))
                for index in range(matrix.shape[1]):
                    result.append("{}[{}]".format(branch, index))
        else:
            try:
                for index in range(len(data[branch][0])):
                    result.append("{column}[{index}]".format(column=branch, index=index))
            except TypeError:
                result.append(branch)
    return result
Lists branches in the file, vector branches, say D_p, turns into D_p[0], D_p[1], D_p[2], D_p[3].
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/rootutilities.py/list_flat_branches