Add new routine to reverse tree math
Fix coding style and remove white spaces.