import copy


def apply_slis_to_node_map(sli_list, node_map):
    """Updates the nodes in the node map with the slis from the sli list.

    Args:
        sli_list: A list of SLIs to add to the nodes
        node_map: A dict mapping node names to nodes

    Returns:
        a dict mapping node names to nodes, with updated SLIs
    """

    out_node_map = copy.deepcopy(node_map)

    for sli in sli_list:
        node = out_node_map[sli.node_name]
        # find the index of the node's SLI with the same SLI type as the SLI from sli_list

        new_node_slis = []

        for node_sli in node.slis:
            if node_sli.sli_type == sli.sli_type:
                new_node_slis.append(sli)
            else:
                new_node_slis.append(node_sli)

        del node.slis[:]
        node.slis.extend(new_node_slis)

    return out_node_map