static Collection treeSetClusters_add(Map> clusters, L l) {
for (int i = 0; i < l(l)-1; i++)
treeSetClusters_add(clusters, l.get(i), l.get(i+1));
ret clusters.get(first(l));
}
static void treeSetClusters_add(Map> clusters, A a, A b) {
if (eq(a, b)) {
Collection cluster = clusters.get(a);
if (cluster == null)
clusters.put(a, littreeset(a));
ret;
}
Collection clusterA = clusters.get(a);
Collection clusterB = clusters.get(b);
if (clusterA == null && clusterB == null) {
L cluster = ll(a, b);
clusters.put(a, cluster);
clusters.put(b, cluster);
} else if (clusterA == null) {
clusterB.add(a);
clusters.put(a, clusterB);
} else if (clusterB == null) {
clusterA.add(b);
clusters.put(b, clusterA);
} else if (clusterA != clusterB)
treeSetClusters_merge(clusters, clusterA, clusterB);
}