Implement depth calculation for pages