<s> import collections <EOL> def nested_update ( d , u ) : <EOL> for k , v in u . iteritems ( ) : <EOL> if isinstance ( v , collections . Mapping ) : <EOL> r = nested_update ( d . get ( k , { } ) , v ) <EOL> d [ k ] = r <EOL> elif isinstance ( v , collections . Iterable ) : <EOL> try : <EOL> d [ k ] . extend ( u [ k ] ) <EOL> except KeyError : <EOL> d [ k ] = u [ k ] <EOL> else : <EOL> d [ k ] = u [ k ] <EOL> return d <EOL> def dict_depth ( d , depth = <NUM_LIT:0> ) : <EOL> if not isinstance ( d , dict ) or not d : <EOL> return depth <EOL> return max ( dict_depth ( v , depth + <NUM_LIT:1> ) <EOL> for k , v in d . iteritems ( ) ) </s>
