from typing import Mapping


def update_nested(original_dict, update_dict):
    """Update a nested dictionary with another nested dictionary.
    Has equivalent behaviour to :obj:`dict.update(self, update_dict)`.

    Args:
        original_dict (dict): The original dictionary to update.
        update_dict (dict): The dictionary from which to extract updates.
    Returns:
        original_dict (dict): The original dictionary after updates.
    """
    for k, v in update_dict.items():
        nested_dict = v
        if isinstance(v, Mapping):  # Mapping ~= any dict-like object
            nested_dict = original_dict.get(k, {})
            if nested_dict is not None:
                nested_dict = update_nested(nested_dict, v)
        original_dict[k] = nested_dict
    return original_dict