Function to fill hd in set .
def fillSet ( root , s , hd ) : NEW_LINE INDENT if ( not root ) : NEW_LINE INDENT return NEW_LINE DEDENT fillSet ( root . left , s , hd - 1 ) NEW_LINE s . add ( hd ) NEW_LINE fillSet ( root . right , s , hd + 1 ) NEW_LINE DEDENT def verticalWidth ( root ) : NEW_LINE INDENT s = set ( ) NEW_LINE DEDENT