Improved traveseing logic, use stack to tracing info.