diff --git a/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php
index 8cc5be8..38ca761 100644
--- a/core/modules/taxonomy/src/TermStorage.php
+++ b/core/modules/taxonomy/src/TermStorage.php
@@ -9,7 +9,6 @@
 
 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
 use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\Query\QueryInterface;
 
 /**
  * Defines a Controller class for taxonomy terms.
@@ -135,8 +134,15 @@ public function loadParents($tid) {
       $query->addTag('term_access');
       $query->orderBy('t.weight');
       $query->orderBy('t.name');
-      if ($ids = $query->execute()->fetchCol()) {
-        $parents = $this->loadMultiple($ids);
+      $ids = $query->execute()->fetchCol();
+      if ($ids) {
+        // If there is a <root> parent in the list, it will be filtered out in
+        // loadMultiple() because there's no entity associated with the <root>.
+        // In this case, the parent is added with key 0 and NULL.
+        if (in_array(0, $ids)) {
+          $parents[0] = NULL;
+        }
+        $parents += $this->loadMultiple($ids);
       }
       $this->parents[$tid] = $parents;
     }
@@ -156,7 +162,7 @@ public function loadAllParents($tid) {
         while ($tid = array_shift($terms_to_search)) {
           if ($new_parents = $this->loadParents($tid)) {
             foreach ($new_parents as $new_parent) {
-              if (!isset($parents[$new_parent->id()])) {
+              if ($new_parent && !isset($parents[$new_parent->id()])) {
                 $parents[$new_parent->id()] = $new_parent;
                 $terms_to_search[] = $new_parent->id();
               }
diff --git a/core/modules/taxonomy/src/Tests/TermKernelTest.php b/core/modules/taxonomy/src/Tests/TermKernelTest.php
index 9074375..83723d8 100644
--- a/core/modules/taxonomy/src/Tests/TermKernelTest.php
+++ b/core/modules/taxonomy/src/Tests/TermKernelTest.php
@@ -8,7 +8,6 @@
 namespace Drupal\taxonomy\Tests;
 
 use Drupal\taxonomy\Entity\Term;
-use Drupal\taxonomy\Tests\TaxonomyTestTrait;
 use Drupal\simpletest\KernelTestBase;
 
 /**
@@ -153,4 +152,31 @@ public function testTaxonomyVocabularyTree() {
     $ancestors = $storage->loadAllParents($term[3]->id());
     $this->assertEqual(5, count($ancestors), 'The term has five ancestors including the term itself.');
   }
+
+  /**
+   * Tests if all the parents are loaded for a taxonomy term.
+   *
+   * @covers \Drupal\taxonomy\TermStorage::loadParents()
+   */
+  public function testLoadParents() {
+    /** @var \Drupal\taxonomy\TermStorageInterface $storage */
+    $storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
+    $vocabulary = $this->createVocabulary();
+    $parent = $this->createTerm($vocabulary, ['weight' => 10]);
+    $term = $this->createTerm($vocabulary);
+
+    // Make <root> and $parent parents of $term.
+    $term->parent = [$parent->id(), 0];
+    $term->save();
+
+    // Load the parents from the backend.
+    $parents = $storage->loadParents($term->id());
+
+    // Both parents should have been loaded.
+    $this->assertIdentical(count($parents), 2);
+    $this->assertTrue(array_key_exists(0, $parents));
+    $this->assertNull($parents[0]);
+    $this->assertIdentical($parents[1]->id(), $parent->id());
+  }
+
 }
