LPS-39587 third attempt

For merging Elements, this is how it works.  I explain below:
1-First, if first and second element name are the same, just change the text to the merged element.
2-In this iteration, check if there are any array elements in first element, and the same element exists in second element. In that case, remove the first element's array.
3-In the next iteration, after making sure that all first elements should be simple ones (without any arrays), continue and merge the rest of the elements.
4-Finally, add the array elements existent in the second element to be merged (we removed those arrays in step 2).