Print one level at a time
while ( nodeCount ) : NEW_LINE INDENT node = q [ 0 ] NEW_LINE print ( node . data , end = " ▁ " ) NEW_LINE q . pop ( 0 ) NEW_LINE if ( node . left != None ) : NEW_LINE INDENT q . append ( node . left ) NEW_LINE DEDENT if ( node . right != None ) : NEW_LINE INDENT q . append ( node . right ) NEW_LINE DEDENT nodeCount -= 1 NEW_LINE DEDENT