function assertStructureMatchesReferenceInner(element, reference) {
  if (!element && !reference) {
    return;
  }
  testingAsserts.assertTrue('Expected two elements.', !!element && !!reference);
  testingAsserts.assertEquals(
      'Expected nodes to have the same nodeName.', element.nodeName,
      reference.nodeName);
  const testElem = asserts.assertElement(element);
  const refElem = asserts.assertElement(reference);
  const elementClasses = classlist.get(testElem);
  Array.prototype.forEach.call(classlist.get(refElem), (referenceClass) => {
    testingAsserts.assertContains(
        'Expected test node to have all reference classes.', referenceClass,
        elementClasses);
  });
  // Call assertStructureMatchesReferenceInner_ on all element children
  // unless this is a content node
  const elChildren = getElementChildren(element);
  const refChildren = getElementChildren(reference);

  if (!isContentNode(reference)) {
    if (elChildren.length != refChildren.length) {
      assertEquals(
          'Expected same number of children for a non-content node.',
          elChildren.length, refChildren.length);
    }
    for (let i = 0; i < elChildren.length; i++) {
      assertStructureMatchesReferenceInner(elChildren[i], refChildren[i]);
    }
  }
}
A recursive function for comparing structure, node names, and classes between
a test and reference DOM structure. Throws an error if one of these things
doesn't match. Used internally by
{@link assertStructureMatchesReference}.
@param {?Node} element DOM element to test.
@param {?Node} reference DOM element to use as a reference (test against).