How is search.max_buckets calculated? ES 7.5.0

I'm wondering how search.max_buckets is calculated. I have a multilevel terms aggregation. We have 10,000 leaf node buckets. Do the parent buckets count as part of the 10,000 limit?

Parent buckets do count. Metric aggs don't. If you are willing to upgrade we've bumped the limit to 65535 and dropped it from all stages but the final reduce. Other than that we use real memory usage to limit. But you'd want to upgrade to get it.

Thank you, this helps.