How to import taxonomy with hierarchy? We're upgrading our site from D7 to D8, which has vocabulary containing multi-level parent-child hierarchy. The list is too long (around 5K-10K terms) to import manually.

We've tried using migrate in D8 Core and extending it using migrate_plus and migrate_tools module. These works really well when there is no term hierarchy.

How can we get it working for importing term with hierarchy. The value it accepts for parent is term id. If we pass the parent name (as we're importing it for first-time), it creates the term at root level. Are we missing anything? If we can not do this only with these modules,  how can we extend these modules. References would also greatly appreciated.
If you want to import Taxonomy with Hierarchy along with the existing tid then follow the following.
Configure your import configuration some thing like this

id: taxonomy_migration
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
 - CSV
migration_group: null
label: 'Taxonomy migration from CSV'
source:
  plugin: csv
  path: test.csv //path of file
  header_row_count: 1
  keys:
    - tid //unique key which is used for mapping while importing other content related with this taxonomy
process:
  parent: //this is for your parent term id
    plugin: migration_lookup
    migration: taxonomy_migration //this is the current migration id which will help you to make parent child on taxonomy
    source: pid //parent id source from your csv file
  name: term
  tid: tid
destination:
  plugin: 'entity:taxonomy_term'
  default_bundle: test_taxonomy //your vocabulary machine name where you want to import 
migration_dependencies: null
migration_dependencies: null


now your csv file will be like this



now you can check your taxonomy, result will be like in the image below with existing tid.