docs: def num_nodes(self, leaves=True, internal=True):
          '''Compute the total number of selected nodes in this ``Tree``
  
          Args:
              ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False``
  
              ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
  
          Returns:
              ``int``: The total number of selected nodes in this ``Tree``
          '''
          if not isinstance(leaves, bool):
              raise TypeError("leaves must be a bool")
          if not isinstance(internal, bool):
              raise TypeError("internal must be a bool")
          num = 0
          for node in self.traverse_preorder():
              if (leaves and node.is_leaf()) or (internal and not node.is_leaf()):
                  num += 1
          return num