Detect maximum nest depth