code: public static Node normalizeWhitespace(Node original) {
          Node cloned = original.cloneNode(true);
          cloned.normalize();
          handleWsRec(cloned, true);
          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 and normalized.
  
  <p>"normalized" in this context means all whitespace characters
  are replaced by space characters and consecutive whitespace
  characaters are collapsed.</p>