code: def _build_cmd_tree(self, cmd_cls, cmd_name=None):
          
          if isinstance(cmd_cls, type):
              cmd_obj = cmd_cls()
          else:
              cmd_obj = cmd_cls
          if cmd_name is None:
              cmd_name = cmd_obj.get_cmd_name()
          return cmd_tree_node(cmd_name, cmd_obj, tuple([
              self._build_cmd_tree(subcmd_cls, subcmd_name)
              for subcmd_name, subcmd_cls in cmd_obj.get_sub_commands()]))
docs: Build a tree of commands.
  
          :param cmd_cls:
              The Command class or object to start with.
          :param cmd_name:
              Hard-coded name of the command (can be None for auto-detection)
          :returns:
              A tree structure represented as tuple
                  ``(cmd_obj, cmd_name, children)``
              Where ``cmd_obj`` is a Command instance, cmd_name is its name, if
              any (it might be None) and ``children`` is a tuple of identical
              tuples.
  
          Note that command name auto-detection relies on
          :meth:`guacamole.recipes.cmd.Command.get_cmd_name()`.
  
          Let's look at a simple git-like example::
  
              >>> from guacamole import Command
  
              >>> class git_log(Command):
              >>>     pass
  
              >>> class git_stash_list(Command):
              >>>     pass
  
              >>> class git_stash(Command):
              >>>     sub_commands = (('list', git_stash_list),)
  
              >>> class git(Command):
              >>>     sub_commands = (('log', git_log),
              >>>                     ('stash', git_stash))
  
              >>> build_cmd_tree(git)
              (None, '<git>', (
                  ('log', <git_log>, ()),
                  ('stash', <git_stash>, (
                      ('list', <git_stash_list>, ()),),),),)