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