Accepted solution to getting tree min depth