def WalkControl(control: Control, includeTop: bool = False, maxDepth: int = <NUM_LIT>):
if includeTop:<EOL><INDENT>yield control, <NUM_LIT:0><EOL><DEDENT>if maxDepth <= <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>depth = <NUM_LIT:0><EOL>child = control.GetFirstChildControl()<EOL>controlList = [child]<EOL>while depth >= <NUM_LIT:0>:<EOL><INDENT>lastControl = controlList[-<NUM_LIT:1>]<EOL>if lastControl:<EOL><INDENT>yield lastControl, depth + <NUM_LIT:1><EOL>child = lastControl.GetNextSiblingControl()<EOL>controlList[depth] = child<EOL>if depth + <NUM_LIT:1> < maxDepth:<EOL><INDENT>child = lastControl.GetFirstChildControl()<EOL>if child:<EOL><INDENT>depth += <NUM_LIT:1><EOL>controlList.append(child)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>del controlList[depth]<EOL>depth -= <NUM_LIT:1><EOL><DEDENT><DEDENT>
control: `Control` or its subclass.
includeTop: bool, if True, yield (control, 0) first.
maxDepth: int, enum depth.
Yield 2 items tuple(control: Control, depth: int).