code: def add_layer(self, layer):
          
          assert (
              isinstance(layer,
                         (TiledTileLayer, TiledImageLayer, TiledObjectGroup)))
  
          self.layers.append(layer)
          self.layernames[layer.name] = layer
docs: Add a layer (TileTileLayer, TiledImageLayer, or TiledObjectGroup)
  
          :param layer: TileTileLayer, TiledImageLayer, TiledObjectGroup object