docs: def root2hdf5(rfile, hfile, rpath='',
                entries=-1, userfunc=None,
                show_progress=False,
                ignore_exception=False,
                **kwargs):
      """
      Convert all trees in a ROOT file into tables in an HDF5 file.
  
      Parameters
      ----------
  
      rfile : string or asrootpy'd ROOT File
          A ROOT File handle or string path to an existing ROOT file.
  
      hfile : string or PyTables HDF5 File
          A PyTables HDF5 File handle or string path to an existing HDF5 file.
  
      rpath : string, optional (default='')
          Top level path to begin traversal through the ROOT file. By default
          convert everything in and below the root directory.
  
      entries : int, optional (default=-1)
          The number of entries to read at once while converting a ROOT TTree
          into an HDF5 table. By default read the entire TTree into memory (this
          may not be desired if your TTrees are large).
  
      userfunc : callable, optional (default=None)
          A function that will be called on every tree and that must return a
          tree or list of trees that will be converted instead of the original
          tree.
  
      show_progress : bool, optional (default=False)
          If True, then display and update a progress bar on stdout as each tree
          is converted.
  
      ignore_exception : bool, optional (default=False)
          If True, then ignore exceptions raised in converting trees and instead
          skip such trees.
  
      kwargs : dict, optional
          Additional keyword arguments for the tree2array function.
  
      """
      own_rootfile = False
      if isinstance(rfile, string_types):
          rfile = root_open(rfile)
          own_rootfile = True
  
      own_h5file = False
      if isinstance(hfile, string_types):
          hfile = tables_open(filename=hfile, mode="w", title="Data")
          own_h5file = True
  
      for dirpath, dirnames, treenames in rfile.walk(
              rpath, class_ref=QROOT.TTree):
  
          # skip directories w/o trees
          if not treenames:
              continue
  
          treenames.sort()
  
          group_where = '/' + os.path.dirname(dirpath)
          group_name = os.path.basename(dirpath)
  
          if not group_name:
              group = hfile.root
          elif TABLES_NEW_API:
              group = hfile.create_group(group_where, group_name,
                                         createparents=True)
          else:
              group = hfile.createGroup(group_where, group_name)
  
          ntrees = len(treenames)
          log.info(
              "Will convert {0:d} tree{1} in {2}".format(
                  ntrees, 's' if ntrees != 1 else '',
                  os.path.join(group_where, group_name)))
  
          for treename in treenames:
  
              input_tree = rfile.Get(os.path.join(dirpath, treename))
  
              if userfunc is not None:
                  tmp_file = TemporaryFile()
                  # call user-defined function on tree and get output trees
                  log.info("Calling user function on tree '{0}'".format(
                      input_tree.GetName()))
                  trees = userfunc(input_tree)
  
                  if not isinstance(trees, list):
                      trees = [trees]
  
              else:
                  trees = [input_tree]
                  tmp_file = None
  
              for tree in trees:
                  try:
                      tree2hdf5(tree, hfile, group=group,
                                entries=entries,
                                show_progress=show_progress,
                                **kwargs)
                  except Exception as e:
                      if ignore_exception:
                          log.error("Failed to convert tree '{0}': {1}".format(
                              tree.GetName(), str(e)))
                      else:
                          raise
  
              input_tree.Delete()
  
              if userfunc is not None:
                  for tree in trees:
                      tree.Delete()
                  tmp_file.Close()
  
      if own_h5file:
          hfile.close()
      if own_rootfile:
          rfile.Close()