Fix Add.flatten when terms have S.NaN

See github's issue #2633