List<DTNode<StringLabel,StringLabel>> commonChilds = new ArrayList<DTNode<StringLabel,StringLabel>>();
Set<Pair> childsA = new TreeSet<Pair>();
Set<Pair> childsB = new TreeSet<Pair>();
Map<Pair, DTNode<StringLabel,StringLabel>> pairMap = new TreeMap<Pair, DTNode<StringLabel,StringLabel>>();
Pair pair;
// We need common edge label pairs to find common children
for (DTLink<StringLabel,StringLabel> edge : rootA.linksOut()) {
pair = new Pair(Integer.parseInt(edge.tag().toString()), Integer.parseInt(edge.to().label().toString()));
childsA.add(pair);
pairMap.put(pair, edge.to());
}
for (DTLink<StringLabel,StringLabel> edge : rootB.linksOut()) {
pair = new Pair(Integer.parseInt(edge.tag().toString()), Integer.parseInt(edge.to().label().toString()));
childsB.add(pair);
pairMap.put(pair, edge.to());
}
// If root nodes have an equivalence like relation
for (Pair childA : childsA) {
if (childA.getSecond() == Integer.parseInt(rootB.label().toString()) && childsB.contains(new Pair(childA.getFirst(), Integer.parseInt(rootA.label().toString())))) {
commonChilds.add(null);
}
}
childsA.retainAll(childsB); // intersect the sets