Added depth calculation to tree