static modifyNodes(nodes, patchNode) {
    const TXml = shaka.util.TXml;

    const paths = TXml.parseXpath(patchNode.attributes['sel'] || '');
    if (!paths.length) {
      return;
    }
    const lastNode = paths[paths.length - 1];
    const position = patchNode.attributes['pos'] || null;

    let index = lastNode.position;
    if (index == null) {
      if (lastNode.t !== null) {
        index = TXml.nodePositionByAttribute_(nodes, 't', lastNode.t);
      }
      if (lastNode.n !== null) {
        index = TXml.nodePositionByAttribute_(nodes, 'n', lastNode.n);
      }
    }
    if (index === null) {
      index = position === 'prepend' ? 0 : nodes.length;
    } else if (position === 'prepend') {
      --index;
    } else if (position === 'after') {
      ++index;
    }
    const action = patchNode.tagName;
    const attribute = lastNode.attribute;

    // Modify attribute
    if (attribute && nodes[index]) {
      TXml.modifyNodeAttribute(nodes[index], action, attribute,
          TXml.getContents(patchNode) || '');
    // Rearrange nodes
    } else {
      if (action === 'remove' || action === 'replace') {
        nodes.splice(index, 1);
      }
      if (action === 'add' || action === 'replace') {
        const newNodes = patchNode.children;
        nodes.splice(index, 0, ...newNodes);
      }
    }
  }
Modifies nodes in specified array by adding or removing nodes
and updating attributes.
@param {!Array<shaka.extern.xml.Node>} nodes
@param {!shaka.extern.xml.Node} patchNode