Minimize I and B tags in the DOM (new nodes only)

* This function merges adjacent nodes of the same type
  and swaps nodes where possible to enable further merging.
  See examples below.

  1. <b>X</b><b>Y</b>
     ==> <b>XY</b>

  2. <i>A</i><b><i>X</i></b><b><i>Y</i></b><i>Z</i>
     ==> <i>A<b>XY</b>Z</i>

* This algorithm only merges:
  - non-encapsulated nodes
  - new nodes (or a new node with an old node)
  - similar nodes
    . wikitext nodes
    . HTML nodes with identical attributes

* This patch only adds the algorithm to the codebase without
  integrating it into the serializer.  Once we are happy with
  the algorithm and what it does (and its structure), I'll
  integrate it into the serializer.

* Can be tested as follows:

$ node
> var U = require('./mediawiki.Util.js').Util;
> var M = require('./dom.minimizeWTQuoteTags.js').minimizeWTQuoteTags;
> M(U.parseHTML("<b>X</b><b>Y</b>")).outerHTML
...
> M(U.parseHTML("<b>X</b><i><b>Y</b></i><b>Z</b>")).outerHTML
...

Change-Id: I3cb6b0d032efbc66f8a42c9b528d99dfafa6a880
Merge "Minimize I and B tags in the DOM (new nodes only)"