for(A4Tuple tuple: (A4TupleSet) (instance.eval(rel))) if (tuple.atom(0).equals(atom)) {
if (tuple.arity()==2) ans.add(tuple.atom(1)); else ans.add(tuple);
}
} else if (parent instanceof A4Tuple) {
A4Tuple tp = (A4Tuple)parent;
for(int i=1; i<tp.arity(); i++) if (!ans.contains(tp.atom(i))) ans.add(tp.atom(i));
return ans; // we don't want to sort this; we want the original order
}
Collections.sort(ans, new Comparator<Object>() {
public int compare(Object a, Object b) {
String t1, t2;