code: def attr_chain(obj, attr):
      """Follow an attribute chain.
  
      If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
      use this to iterate over all objects in the chain. Iteration is
      terminated by getattr(x, attr) is None.
  
      Args:
          obj: the starting object
          attr: the name of the chaining attribute
  
      Yields:
          Each successive object in the chain.
      """
      next = getattr(obj, attr)
      while next:
          yield next
          next = getattr(next, attr)
  
imports: from itertools import islice
  from .pgen2 import token
  from .pytree import Leaf, Node
  from .pygram import python_symbols
  from .None import patcomp
label_desc: Use image node_id 21 for calling a global function with example usage: attr_chain(obj, attr) without return types