identifyLayers () {
    this.all_layers = []
    this.layer_map = {}
    const numchildren = this.svgElem_.childNodes.length
    // loop through all children of SVG element
    const orphans = []
    const layernames = []
    let layer = null
    let childgroups = false
    for (let i = 0; i < numchildren; ++i) {
      const child = this.svgElem_.childNodes.item(i)
      // for each g, find its layer name
      if (child?.nodeType === 1) {
        if (child.tagName === 'g') {
          childgroups = true
          if (isLayerElement(child)) {
            const name = findLayerNameInGroup(child)
            layernames.push(name)
            layer = new Layer(name, child)
            this.all_layers.push(layer)
            this.layer_map[name] = layer
          } else {
            // if group did not have a name, it is an orphan
            orphans.push(child)
          }
        } else if (visElems.includes(child.nodeName)) {
          // Child is "visible" (i.e. not a <title> or <defs> element), so it is an orphan
          orphans.push(child)
        }
      }
    }

    // If orphans or no layers found, create a new layer and add all the orphans to it
    if (orphans.length > 0 || !childgroups) {
      const name = getNewLayerName(layernames)
      layer = new Layer(name, null, this.svgElem_)
      layer.appendChildren(orphans)
      this.all_layers.push(layer)
      this.layer_map[name] = layer
    } else {
      layer.activate()
    }
    this.current_layer = layer
  }
Updates layer system and sets the current layer to the
top-most layer (last `<g>` child of this drawing).
@returns {void}