How can I simplify and optimize this code?
if type(variant_list) == dict:
style_color_if(variant_list[style_colors_main], variant_list)
else:
for variant in variant_list:
if type(variant[style_colors_main]) == dict:
json_key_getter(variant[style_colors_main], variant)
else:
for styleColors in variant[style_colors_main]:
if type(styleColors) == dict:
json_key_getter(styleColors, variant)
else:
for styleColor in styleColors:
json_key_getter(styleColor, variant)
Example of one element of variant list, variant list can have one such thing or many: