Use isinstance to make it work for subclasses of dict and list