Using Drupal 8's Migrate API, how can I map a nested (hierarchical) taxonomy term to the imported entity?
On my project, I created a group migration with two migrations


taxonomy migration all taxonomy term.
taxonomy_parent update parent for terms have parent.


There are example code (I use the embedded_data source plugin for the sake of simplicity so that this example can be copy-pasted as a working example ) and source like that:


Migration group: migrate_plus.migration_group.taxonomy.yml

id: taxonomy
label: Import Taxonmy
description: Import Taxonomy.


Migration all term: migrate_plus.migration.taxonomy.yml

id: taxonomy
label: Import term taxonomy
migration_group: taxonomy
source:
  plugin: embedded_data
  data_rows:
    -
      id: 1
      name: 'Parent 1'
    -
      id: 2
      name: 'Children 1'
    -
      id: 3
      name: 'Children 2'
    -
      id: 4
      name: 'Children children 1'
  ids:
    id:
      type: integer
destination:
  plugin: entity:taxonomy_term
  default_bundle: custom_taxonomy
process:
  name: name


Set parent for term: migrate_plus.migration.taxonomy_parent.yml

id: taxonomy_parent
label: Set parent taxonomy
migration_group: taxonomy
source:
  plugin: embedded_data
  data_rows:
    -
      id: 2
      parent: 1
    -
      id: 3
      parent: 1
    -
      id: 4
      parent: 2
  ids:
    id:
      type: integer
destination:
  plugin: entity:taxonomy_term
  default_bundle: custom_taxonomy
  overwrite_properties:
    - parent
process:
  tid:
    plugin: migration_lookup
    migration: taxonomy
    source: id
  pid:
    plugin: migration_lookup
    migration: taxonomy
    source: parent
  parent: '@pid'


and result: