Merge - updated the merge function to work for any depth

The solution is not as pretty as the original one, but it works well.  Appropriate unit tests are in place.