Index: src/Form/SettingsForm.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php
--- a/src/Form/SettingsForm.php	(revision 1d8df735c6a4792470dda8153b021672816efb28)
+++ b/src/Form/SettingsForm.php	(date 1666167403332)
@@ -82,11 +82,18 @@
       '#default_value' => \Drupal::config('permissions_by_term.settings')->get('disable_node_access_records'),
     ];

+    $form['only_parents'] = [
+      '#type'          => 'checkbox',
+      '#title'         => t('Show only the parent terms'),
+      '#description'   => t('Check this if you doesn\'t want to show terms children but only the parents.'),
+      '#default_value' => $this->config('permissions_by_term.settings')->get('only_parents') ?? false
+    ];
+
     $form['target_bundles'] = [
-      '#type' => 'checkboxes',
-      '#title' => $this->t('Limit by taxonomy vocabularies'),
-      '#description' => $this->t('Whether to limit permissions management and search by selected taxonomy vocabularies. If left empty, all taxonomy vocabularies are allowed.'),
-      '#options' => $this->getTaxonomyVocabularyOptions(),
+      '#type'          => 'checkboxes',
+      '#title'         => $this->t('Limit by taxonomy vocabularies'),
+      '#description'   => $this->t('Whether to limit permissions management and search by selected taxonomy vocabularies. If left empty, all taxonomy vocabularies are allowed.'),
+      '#options'       => $this->getTaxonomyVocabularyOptions(),
       '#default_value' => $this->config('permissions_by_term.settings')->get('target_bundles') ?? [],
     ];

@@ -109,29 +116,29 @@
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    \Drupal::configFactory()
+    $this->configFactory
       ->getEditable('permissions_by_term.settings')
       ->set('require_all_terms_granted', $form_state->getValue('require_all_terms_granted'))
       ->save();

-    \Drupal::configFactory()
+    $this->configFactory
       ->getEditable('permissions_by_term.settings')
       ->set('permission_mode', $form_state->getValue('permission_mode'))
       ->save();

-    if ($form_state->getValue('disable_node_access_records') && !\Drupal::configFactory()
+    if ($form_state->getValue('disable_node_access_records') && !$this->configFactory
         ->getEditable('permissions_by_term.settings')
         ->get('disable_node_access_records')) {
       node_access_rebuild(true);
     }

-    if (!$form_state->getValue('disable_node_access_records') && \Drupal::configFactory()
+    if (!$form_state->getValue('disable_node_access_records') && $this->configFactory
         ->getEditable('permissions_by_term.settings')
         ->get('disable_node_access_records')) {
       node_access_rebuild(true);
     }

-    \Drupal::configFactory()
+    $this->configFactory
       ->getEditable('permissions_by_term.settings')
       ->set('disable_node_access_records', $form_state->getValue('disable_node_access_records'))
       ->save();
@@ -141,6 +148,11 @@
       ->getEditable('permissions_by_term.settings')
       ->set('target_bundles', array_values($bundles))
       ->save();
+
+    $this->configFactory
+      ->getEditable('permissions_by_term.settings')
+      ->set('only_parents', $form_state->getValue('only_parents'))
+      ->save();

     parent::submitForm($form, $form_state);
   }
Index: permissions_by_term.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/permissions_by_term.module b/permissions_by_term.module
--- a/permissions_by_term.module	(revision 1d8df735c6a4792470dda8153b021672816efb28)
+++ b/permissions_by_term.module	(date 1666166969568)
@@ -249,9 +249,10 @@

   $settings = \Drupal::config('permissions_by_term.settings');
   $target_bundles = $settings->get('target_bundles');
+  $only_parents   = $settings->get('only_parents');
   $terms = $target_bundles
-    ? $term_storage->loadByProperties(['vid' => $target_bundles])
-    : $term_storage->loadMultiple();
+    ? $term_storage->loadByProperties(['vid' => $target_bundles] + ($only_parents ? ['parent' => 0] : []))
+    : ($only_parents ? $term_storage->loadByProperties(['parent' => 0]) : $term_storage->loadMultiple());

   $form['access']['terms'] = [
     '#type' => 'select',
