function walk(node, fn) {
  if (node.childNodes) {
    for (let i = 0, l = node.childNodes.length; i < l; i++) {
      const child = node.childNodes[i];
      const stop = fn(child);

      if (!stop) {
        walk(child, fn);
      }
    }
  } // also walk shadow DOM


  if (node.shadowRoot) {
    walk(node.shadowRoot, fn);
  }
}
DOM walk helper

@param {NodeList} nodes
@param {Function} fn