Properly handle nested types when converting to map.

@swankjesse @danrice-square