docs: def _remove_unused_nodes(self):
          """
          Removes unused function and sub-dispatcher nodes.
          """
  
          # Namespace shortcuts.
          nodes, wf_remove_node = self.nodes, self.workflow.remove_node
          add_visited, succ = self._visited.add, self.workflow.succ
  
          # Remove unused function and sub-dispatcher nodes.
          for n in (set(self._wf_pred) - set(self._visited)):
              node_type = nodes[n]['type']  # Node type.
  
              if node_type == 'data':
                  continue  # Skip data node.
  
              if node_type == 'dispatcher' and succ[n]:
                  add_visited(n)  # Add to visited nodes.
                  i = self.index + nodes[n]['index']
                  self.sub_sol[i]._remove_unused_nodes()
                  continue  # Skip sub-dispatcher node with outputs.
  
              wf_remove_node(n)