def flatten(json_payload):
    """take a dictionary with embedded dictionaries and convert to a single depth dictionary

    Args:
        json_payload ([dict]): [dictionary to flatten]

    Returns:
        [dict]: [flattened dictionary]
    """
    result = {}
    for item, item_value in json_payload.items():
        if isinstance(item_value, dict):
            flatten_result = flatten(item_value)
            # append the dictionary flattended to the existing dictionary
            result = {**result, **flatten_result}
        else:
            result[item] = item_value
    return result