code: def __next__(self):
      while self.stack:
          component = self.stack.pop()
  
          if isinstance(component, lightning.app.LightningFlow):
              self.stack += list(component.flows.values())
              self.stack += component.works(recurse=False)
  
          if any(isinstance(component, t) for t in self.types):
              return component
  
      raise StopIteration
  
file_path: pytorch-lightning/src/lightning/app/utilities/tree.py
imports: from typing import TYPE_CHECKING, Type
  import lightning.app
label_desc: Use image node_id 3 for calling the _DepthFirstVisitor obj's underlying member method code with example usage: obj.__next__() and returns: component