Cache node_depth for improved performance
Fixed bug raised in #37 discussion