code: def IsTopLevel(self) -> bool:
          
          handle = self.NativeWindowHandle
          if handle:
              return GetAncestor(handle, GAFlag.Root) == handle
          return False
docs: Determine whether current control is top level.