Update trace.py

Improve _validate logic so there is one single point of return.