Add the ability to merge nodes that are next to each other

When a new selection is next are to another one, we try to merge the nodes together, if a selection is in the middle of two notes then we can merge them all into one. Also the recursion had been replaced with a NodeIterator so that it uses the browser supported functionality.