function getNodeForNamedElement(sourceElement, translatedChild) {
  const childName = translatedChild.getAttribute("data-l10n-name");
  const sourceChild = sourceElement.querySelector(
    `[data-l10n-name="${childName}"]`
  );

  if (!sourceChild) {
    console.warn(`An element named "${childName}" wasn't found in the source.`);
    return createTextNodeFromTextContent(translatedChild);
  }

  if (sourceChild.localName !== translatedChild.localName) {
    console.warn(
      `An element named "${childName}" was found in the translation ` +
        `but its type ${translatedChild.localName} didn't match the ` +
        `element found in the source (${sourceChild.localName}).`
    );
    return createTextNodeFromTextContent(translatedChild);
  }

  // Remove it from sourceElement so that the translation cannot use
  // the same reference name again.
  sourceElement.removeChild(sourceChild);
  // We can't currently guarantee that a translation won't remove
  // sourceChild from the element completely, which could break the app if
  // it relies on an event handler attached to the sourceChild. Let's make
  // this limitation explicit for now by breaking the identitiy of the
  // sourceChild by cloning it. This will destroy all event handlers
  // attached to sourceChild via addEventListener and via on<name>
  // properties.
  const clone = sourceChild.cloneNode(false);
  return shallowPopulateUsing(translatedChild, clone);
}
Sanitize a child element created by the translation.

Try to find a corresponding child in sourceElement and use it as the base
for the sanitization. This will preserve functional attribtues defined on
the child element in the source HTML.

@param   {Element} sourceElement - The source for data-l10n-name lookups.
@param   {Element} translatedChild - The translated child to be sanitized.
@returns {Element}
@private