generalize the IsRealExpression[] function to better handle traces