How to use taxonomy term hierarchy

Taxonomy terms can be created with levels of hierarchy. However, I have never, in D7 or D8, been able to find a simple way to get that data out of them on the back end.

When I use DrupaltaxonomyEntityTerm::load(), there’s no data in the returned object about its hierarchical level, nor of its parents or children. I can’t seem to locate any class methods that would get me that information.

The actual hierarchy data is stored in the `taxonomy_term_hierarchy` table, but grepping the entire codebase, the only place that table is accessed from within Taxonomy is from its Views and Migrate plugins, and unit tests. It would be simple enough for me just to write some Drupal::database()->select() statements to grab the data, but has this really not been thought of before? Surely I’m missing something.

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed