docs: def tree2hdf5(tree, hfile, group=None,
                entries=-1, show_progress=False, **kwargs):
      """
      Convert a TTree into a HDF5 table.
  
      Parameters
      ----------
  
      tree : ROOT.TTree
          A ROOT TTree.
  
      hfile : string or PyTables HDF5 File
          A PyTables HDF5 File handle or string path to an existing HDF5 file.
  
      group : string or PyTables Group instance, optional (default=None)
          Write the table at this location in the HDF5 file.
  
      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).
  
      show_progress : bool, optional (default=False)
          If True, then display and update a progress bar on stdout as the TTree
          is converted.
  
      kwargs : dict, optional
          Additional keyword arguments for the tree2array function.
  
      """
      show_progress = show_progress and check_tty(sys.stdout)
      if show_progress:
          widgets = [Percentage(), ' ', Bar(), ' ', ETA()]
  
      own_h5file = False
      if isinstance(hfile, string_types):
          hfile = tables_open(filename=hfile, mode="w", title="Data")
          own_h5file = True
  
      log.info("Converting tree '{0}' with {1:d} entries ...".format(
          tree.GetName(),
          tree.GetEntries()))
  
      if not group:
          group = hfile.root
      elif isinstance(group, string_types):
          group_where = '/' + os.path.dirname(group)
          group_name = os.path.basename(group)
          if TABLES_NEW_API:
              group = hfile.create_group(group_where, group_name,
                                         createparents=True)
          else:
              group = hfile.createGroup(group_where, group_name)
  
      if tree.GetName() in group:
          log.warning(
              "Tree '{0}' already exists "
              "in the output file".format(tree.GetName()))
          return
  
      total_entries = tree.GetEntries()
      pbar = None
      if show_progress and total_entries > 0:
          pbar = ProgressBar(widgets=widgets, maxval=total_entries)
  
      if entries <= 0:
          # read the entire tree
          if pbar is not None:
              pbar.start()
          array = tree2array(tree, **kwargs)
          array = _drop_object_col(array)
          if TABLES_NEW_API:
              table = hfile.create_table(
                  group, tree.GetName(),
                  array, tree.GetTitle())
          else:
              table = hfile.createTable(
                  group, tree.GetName(),
                  array, tree.GetTitle())
          # flush data in the table
          table.flush()
          # flush all pending data
          hfile.flush()
      else:
          # read the tree in chunks
          start = 0
          while start < total_entries or start == 0:
              if start > 0:
                  with warnings.catch_warnings():
                      warnings.simplefilter(
                          "ignore",
                          RootNumpyUnconvertibleWarning)
                      warnings.simplefilter(
                          "ignore",
                          tables.NaturalNameWarning)
                      array = tree2array(
                          tree,
                          start=start,
                          stop=start + entries,
                          **kwargs)
                  array = _drop_object_col(array, warn=False)
                  table.append(array)
              else:
                  array = tree2array(
                      tree,
                      start=start,
                      stop=start + entries,
                      **kwargs)
                  array = _drop_object_col(array)
                  if pbar is not None:
                      # start after any output from root_numpy
                      pbar.start()
                  if TABLES_NEW_API:
                      table = hfile.create_table(
                          group, tree.GetName(),
                          array, tree.GetTitle())
                  else:
                      table = hfile.createTable(
                          group, tree.GetName(),
                          array, tree.GetTitle())
              start += entries
              if start <= total_entries and pbar is not None:
                  pbar.update(start)
              # flush data in the table
              table.flush()
              # flush all pending data
              hfile.flush()
  
      if pbar is not None:
          pbar.finish()
  
      if own_h5file:
          hfile.close()