Get unique elements of an abject array by merging elements with same value of field
<p>There is an array with some objects, which could have elements with the same title (and different type). 
Those elements should be merged to get a result array with unique titles, but the info of the individual object shouldn't get lost.</p>

<p>So this...</p>

<pre><code>array = [
    { id: 1, title: 'one', type: 'infos' },
    { id: 2, title: 'two', type: 'infos' },
    { id: 3, title: 'same', type: 'infos' },   // &lt;--
    { id: 1, title: 'oneDiff', type: 'article' },
    { id: 2, title: 'same', type: 'article' },
    { id: 3, title: 'three', type: 'article' } // &lt;--
]
</code></pre>

<p>...should get:</p>

<pre><code>distinct = [
    { id: 1, title: 'one', type: 'infos' },
    { id: 2, title: 'two', type: 'infos' },
    { id: 1, title: 'oneDiff', type: 'article' },
    { id: 3, title: 'three', type: 'article' },
    { id: [{ id: 3, type: 'infos'}, { id: 2, type: 'article'}], title: 'same', type: 'multiple' }
]
</code></pre>

<p>I tried to start with this, but I failed to get the result I need:</p>

<pre><code>var unique = {};
var distinct = [];
for( var i in array ){
    if( typeof(unique[array[i].title]) == "undefined"){
        distinct.push(array[i].title);
    }
    unique[array[i].title] = 0;
}
</code></pre>