cloneLayer (name, hrService) {
    if (!this.current_layer) {
      return null
    }
    this.current_layer.deactivate()
    // Check for duplicate name.
    if (
      name === undefined ||
      name === null ||
      name === '' ||
      this.layer_map[name]
    ) {
      name = getNewLayerName(Object.keys(this.layer_map))
    }

    // Create new group and add to DOM just after current_layer
    const currentGroup = this.current_layer.getGroup()
    const layer = new Layer(name, currentGroup, this.svgElem_)
    const group = layer.getGroup()

    // Clone children
    const children = [...currentGroup.childNodes]
    children.forEach(child => {
      if (child.localName === 'title') {
        return
      }
      group.append(this.copyElem(child))
    })

    if (hrService) {
      hrService.startBatchCommand('Duplicate Layer')
      hrService.insertElement(group)
      hrService.endBatchCommand()
    }

    // Update layer containers and current_layer.
    const index = this.indexCurrentLayer()
    if (index >= 0) {
      this.all_layers.splice(index + 1, 0, layer)
    } else {
      this.all_layers.push(layer)
    }
    this.layer_map[name] = layer
    this.current_layer = layer
    return group
  }
Creates a copy of the current layer with the given name and makes it the current layer.
@param {string} name - The given name. If the layer name exists, a new name will be generated.
@param {module:history.HistoryRecordingService} hrService - History recording service
@returns {SVGGElement} The SVGGElement of the new layer, which is
    also the current layer of this drawing.