Fix product tree issues

- Apply new tree traversal method to Java code
- Fix comparison of string and integer TSO in JavaScript code
- Fix maximum valid date for JavaScript