code: def simulate(self, n):
          
          self.tree._tree.seed_node.states = self.ancestral_states(n)
          categories = np.random.randint(self.ncat, size=n).astype(np.intc)
  
          for node in self.tree.preorder(skip_seed=True):
              node.states = self.evolve_states(node.parent_node.states, categories, node.pmats)
              if node.is_leaf():
                  self.sequences[node.taxon.label] = node.states
          return self.sequences_to_string()
docs: Evolve multiple sites during one tree traversal