docs: def qteGetAppletFromWidget(widgetObj):
      """
      Return the parent applet of ``widgetObj``.
  
      |Args|
  
      * ``widgetObj`` (**QWidget**): widget (if any) for which the
        containing applet is requested.
  
      |Returns|
  
      * **QtmacsApplet**: the applet containing ``widgetObj`` or **None**.
  
      |Raises|
  
      * **None**
      """
      if widgetObj is None:
          return None
  
      if hasattr(widgetObj, '_qteAdmin'):
          return widgetObj._qteAdmin.qteApplet
  
      # Keep track of the already visited objects to avoid infinite loops.
      visited = [widgetObj]
  
      # Traverse the hierarchy until a parent features the '_qteAdmin'
      # attribute, the parent is None, or the parent is an already
      # visited widget.
      wid = widgetObj.parent()
      while wid not in visited:
          if hasattr(wid, '_qteAdmin'):
              return wid._qteAdmin.qteApplet
          elif wid is None:
              return None
          else:
              visited.append(wid)
              wid = wid.parent()
      return None