List<CompoundConstraint> compoundConstraints = new ArrayList<CompoundConstraint>();
List<Constraint> constraintList = new ArrayList<Constraint>();
compoundConstraints.add(topLevelConstraint);
for (int i = 0; i < compoundConstraints.size(); ++i) {
CompoundConstraint compoundConstraint = compoundConstraints.get(i);
for (Constraint constraint : compoundConstraint.getConstraints()) {
constraintList.add(constraint);
if (constraint instanceof CompoundConstraint) {
compoundConstraints.add((CompoundConstraint) constraint);
}