def update_parent_child_relationships(links_dict, old_id, new_id):
    """
    Update the parent-child relationships after clustering a firework
    by replacing all the instances of old_id with new_id
    Args:
        links_dict (list): Existing parent-child relationship list
        old_id (int): Existing id of the firework
        new_id (int): New id of the firework

    Returns:
        links_dict (list): Updated parent-child relationship list
    """

    # Enumerate child ids and replace it with the new id
    for parent_id in links_dict:
        child_id_list = links_dict[parent_id]
        for index, child_id in enumerate(child_id_list):
            if child_id == old_id:
                child_id_list[index] = new_id
                break

    # Enumerate parent ids and replace it with the new id
    if old_id in links_dict:
        links_dict[new_id] = links_dict.pop(old_id)
    return links_dict