Grouping multiple curves that intersect with each other

global proc initCurves() {
	string $originalCrvs[] = `ls -sl`;
	IntersectCurves;
	CutCurves;
	printOutConnections($originalCrvs);
}
 
global proc printOutConnections(string[] $sel) {
	//convert selection from curve node to curveShape node
	string $cvs[] = `ls -dag -leaf $sel`;
	string $connections1[];
 
	//loop thourgh all of the curveShape nodes
	for($i=0; $i<size($cvs); $i++) {
	    //print current cuvreShape node
	    print($cvs[$i] + "\n");
	    clear($connections1);
 
	    //collect all curveIntersect nodes that are connected to current curveShape node
	    $connections1 = `listConnections -source 1 -destination 1 -type curveIntersect $cvs[$i]`;
	    for($c=0; $c<size($connections1); $c++) {
	        print("\t" + $connections1[$c] + "\n"); 
	        print("\t\t"); print(`listConnections -source 1 -destination 0 -plugs 0 ($connections1[$c] + ".inputCurve1")`);
	        print("\t\t"); print(`listConnections -source 1 -destination 0 -plugs 0 ($connections1[$c] + ".inputCurve2")`);
	        print("\n");
	    }
	    print("\n");
	}
}
 
initCurves();

So analizing this script, looping through the 3 orignal curves prior cuttinng: are curveShape27, curveShape28, curveShape29. To make better sense out of this, curveShape27 and curveShape28 are the 2 curves that create the "T" intersection. Here is a diagram below that shows that curveShape27 and curveShape28 have the same intersecting node called, curveIntersect2. In addition, when analizing by selecting curve27 in the outliner and then curve28 in the outliner, I saw that curve27 is the top->left->leg of the "T" and curve28 is the bottom->leg of the "T". Therefore, curve27DetachedShape2 is the curve, which was not in the original list of curves created in the process when the intersected curves where cut into pieces; leaving it the top->right->leg of the "T"

Now this all sounds great on paper, but I am having a bit of troubles interpeting this into MEL. Any ideas

Maybe to get started, I am thinking I would need to find the locations of all duplicate curveIntersects. I could loop through the curveShape nodes and append the curveIntersects into one big array like so...

global proc findDupLoctations() {
	string $connections1[];
 
	for($i=0; $i<size($cvs); $i++) {
	    //print current cuvreShape node
	    print($cvs[$i] + "\n");
 
	    //collect all curveIntersect nodes that are connected to current curveShape node
	    $connections1[size($connections1)] = `listConnections -source 1 -destination 1 -type curveIntersect $cvs[$i]`;

 ... but the question is how do you find the duplicate locations? I see that MEL has stringArrayCount but that only returns a number of duplicates and you can only compare the array with a string. I even tried using stringArrayRemoveDuplicates and then compare it to the orginal string array but stringArrayRemoveDuplicates only deletes the duplicates and keeps the original item in the array.