Add tree depth calculation