diff --git a/entity.test b/entity.test
index 03c2551..149acd0 100644
--- a/entity.test
+++ b/entity.test
@@ -1466,6 +1466,7 @@ class EntityMetadataIntegrationTestCase extends EntityWebTestCase {
     $book = array('bid' => $node->nid, 'plid' => $node->book['mlid']);
     $node2 = $this->drupalCreateNode(array('type' => 'book', 'book' => $book));
     $node3 = $this->drupalCreateNode(array('type' => 'page'));
+    $node4 = $this->drupalCreateNode(array('type' => 'book', 'book' => array('bid' => 0, 'plid' => -1)));
 
     // Test whether the properties work.
     $wrapper = entity_metadata_wrapper('node', $node2);
@@ -1477,6 +1478,10 @@ class EntityMetadataIntegrationTestCase extends EntityWebTestCase {
     $wrapper = entity_metadata_wrapper('node', $node3);
     $this->assertEmpty($wrapper, 'book');
     $this->assertEmptyArray($wrapper, 'book_ancestors');
+
+    // Test a book node which is not contained in a hierarchy.
+    $wrapper = entity_metadata_wrapper('node', $node4);
+    $this->assertEmptyArray($wrapper, 'book_ancestors');
   }
 
   /**
diff --git a/modules/callbacks.inc b/modules/callbacks.inc
index 26f802e..7db7820 100644
--- a/modules/callbacks.inc
+++ b/modules/callbacks.inc
@@ -29,7 +29,7 @@ function entity_metadata_book_get_properties($node, array $options, $name, $enti
 
     case 'book_ancestors':
       $ancestors = array();
-      while (!empty($node->book['plid'])) {
+      while (!empty($node->book['plid']) && $node->book['plid'] != -1) {
         $link = book_link_load($node->book['plid']);
         array_unshift($ancestors, $link['nid']);
         $node = node_load($link['nid']);
