Recursive json merge algorithm.