JSFiddle - React, Tailwind, and code Playground

JavaScript

var temp = {},
massive_arr = [
    ['a', 'a'], //1
    ['a', 'a'],
    ['a', 'a'],
    ['a', 'b'], //2
    ['a', 'b'],
    ['a', 'b'],
    ['a', 'b'],
    ['a', 'c'], //3
    ['a', 'd'], //4
    ['b', 'a'],
    ['b', 'b'], //5
    ['b', 'b'],
    ['b', 'b'],
    ['b', 'c'], //6
    ['b', 'd'], //7
    ['c', 'a'],
    ['c', 'b'],
    ['c', 'c'], //8
    ['c', 'c'],
    ['c', 'c'],
    ['c', 'd'] //9
    ],
    final_arr = [],
    i = 0,
    id1,
    id2;
for (; i < massive_arr.length; i++) {
    id0 = objectIdentifier(massive_arr[i][0]);
    id1 = objectIdentifier(massive_arr[i][1]);
    
    if (!temp[id0]) {
        temp[id0] = {};
        temp[id0][id1] = 1;
    } else {
        temp[id0][id1] = 1;
    }

    if( id0 === id1 && !temp[id0][id1+"_bis"] ) {
        temp[id0][id1+"_bis"] = 1;
        final_arr.push(massive_arr[i]);
        continue;
    }
    
    if (!temp[id1]) {
        temp[id1] = {};
        temp[id1][id0] = 1;
        final_arr.push(massive_arr[i]);
        continue;
    }

    if (!temp[id1][id0]) {
        temp[id1][id0] = 1;
        final_arr.push(massive_arr[i]);
    }
}
console.log(final_arr);

function objectIdentifier(obj) {
    return obj;
}