diff --git a/relation_entity_collector/relation_entity_collector.module b/relation_entity_collector/relation_entity_collector.module
index 06e5b40..e96aa0a 100644
--- a/relation_entity_collector/relation_entity_collector.module
+++ b/relation_entity_collector/relation_entity_collector.module
@@ -449,7 +449,11 @@ function relation_entity_collector_views_post_execute($view) {
     $ids = array();
     foreach ($view->result as $row) {
       foreach ($collect as $entity_type => $alias) {
-        $ids[$entity_type][] = $row->$alias;
+        // Skip empty values, which may happen for entities that are obtained
+        // via a non-required relationship in the view.
+        if (!empty($row->$alias)) {
+          $ids[$entity_type][] = $row->$alias;
+        }
       }
     }
     foreach ($ids as $entity_type => $entity_ids) {
