code: public static Node stripWhitespace(Node original) {
          Node cloned = original.cloneNode(true);
          cloned.normalize();
          handleWsRec(cloned, false);
          return cloned;
      }
docs: Creates a new Node (of the same type as the original node) that
  is similar to the orginal but doesn't contain any empty text or
  CDATA nodes and where all textual content including attribute
  values or comments are trimmed.