Fix folding logic for conditions.