def GetTopLevelControl(self) -> '<STR_LIT>':
handle = self.NativeWindowHandle<EOL>if handle:<EOL><INDENT>topHandle = GetAncestor(handle, GAFlag.Root)<EOL>if topHandle:<EOL><INDENT>if topHandle == handle:<EOL><INDENT>return self<EOL><DEDENT>else:<EOL><INDENT>return ControlFromHandle(topHandle)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>control = self<EOL>while True:<EOL><INDENT>control = control.GetParentControl()<EOL>handle = control.NativeWindowHandle<EOL>if handle:<EOL><INDENT>topHandle = GetAncestor(handle, GAFlag.Root)<EOL>return ControlFromHandle(topHandle)<EOL><DEDENT><DEDENT><DEDENT>
Get the top level control which current control lays.
If current control is top level, return self.
If current control is root control, return None.
Return `PaneControl` or `WindowControl` or None.