Implemented deep to_dict functionality on models.

Change-Id: Ia14ff3aac22074f24d78a25fcd4b6d4ecaf5ed4a