Collecting constraints in topologically sorted order