Added performance improvements to the is_root? and node_depth.

Thanks to Aidan Steele for the pull request #37.