isinstance(v, dict) preferred over type(...).  Simliar for the other type(...) calls here an in a few other modules.