The problem you have here is that you are just pushing the name. More importantly, you are going to face an issue where what you are trying to find is a complex type so you are going to have to roll your own implementation. Fortunately, that's a pretty trivial thing to do. First of all, you would simply add your own version of indexOf (something like this will do):
Array.prototype.complexIndexOf = function(type) {
for (var x = 0; x < this.length; x++) {
if (this[x].id === type.id && this[x].name === type.name)
return i;
}
return -1;
}
With this prototype in place, you simply change the condition in your for loop to:
if (t.complexIndexOf(array[x]))t.push(array);