Refactor transformParseTree for issue #71