<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_layer(self, element, layer):
 """ add a layer to an existing node or edge Parameters element : str, int, (str/int, str/int) the ID of a node or edge (source node ID, target node ID) layer : str the layer that the element shall be added to """

        assert isinstance(layer, str), "Layers must be strings!"
        if isinstance(element, tuple): # edge repr. by (source, target)
            assert len(element) == 2
            assert all(isinstance(node, (str, int)) for node in element)
            source_id, target_id = element
            # this class is based on a multi-digraph, so we'll have to iterate
            # over all edges between the two nodes (even if there's just one)
            edges = self.edge[source_id][target_id]
            for edge in edges:
                existing_layers = edges[edge]['layers']
                existing_layers.add(layer)
                edges[edge]['layers'] = existing_layers
        if isinstance(element, (str, int)): # node
            existing_layers = self.node[element]['layers']
            existing_layers.add(layer)
            self.node[element]['layers'] = existing_layers