Avoid reprinting nodes whose children can be reprinted.

This reduces the running time of the identity tests from 6.9s to 2.5s, which goes a long way towards addressing issue #18.