code: public static void lazyInsertBefore(Element newElement, Element before) {
          if (!before.parentNode.contains(newElement)) {
              before.parentNode.insertBefore(newElement, before);
          }
      }
docs: Inserts the specified element into the parent of the before element if not already present. If parent already
  contains child, this method does nothing.