def print_root_structure(file_name):
    with rootpy.io.root_open(file_name, "READ") as root_file:
        for path, dirs, objects in root_file.walk():
            # print([path, dirs, objects])
            n_tabs = str.count(path, '/')
            print("\t" * n_tabs, str.split(path, '/')[-1])
            for objName in objects:
                obj = root_file.Get(path + "/" + objName)
                print("\t" * (n_tabs + 1), obj)
Prints the structure of root file in readable format
dataset/ETHPy150Open anaderi/lhcb_trigger_ml/hep_ml/rootutilities.py/print_root_structure