если что, вот на js
const originalData = [[1, 2], [3, 4], [5, 6], [10, 15, 20]];
const iter = (tail) => {
if (tail.length === 1) {
return tail[0].map(i => [i]);
} else {
return tail.shift().map(item => iter([...tail]).map(t => [item, ...t])).flat();
}
};
console.log(iter(originalData));