private function fetchRelatedObjects(ObjectRef $givenObjectRef, QueryContext $queryContext, Scope $scope, $skipBinaries, DOMDocument $domDoc, DOMNode $xmlElement, array &$xmlElementsWithState, array &$allFetchedObjects)
 {
     $hasTerminatedObjects = FALSE;
     $mySQLi = $this->schema->getMySQLi();
     $givenEntity = $givenObjectRef->getEntity();
     foreach ($givenEntity->getRelationships() as $relationship) {
         $otherEntity = $relationship->getOppositeEntity($givenEntity);
         // Ignore relationships with link-entities.
         if ($otherEntity->isObjectEntity()) {
             // Determine the scope of the related object to be fetched.
             $scopeUnitTag = NULL;
             if ($relationship->getOwnerEntity() == $givenEntity) {
                 $scopeUnitTag = Scope::TAG_COMPONENTS;
             } else {
                 if ($relationship->getOwnerEntity() == $otherEntity) {
                     $scopeUnitTag = Scope::TAG_OWNERS;
                 } else {
                     $scopeUnitTag = Scope::TAG_ASSOCIATES;
                 }
             }
             if ($scope->includes($scopeUnitTag) != Scope::INCLUDES_NONE) {
                 $subScope = $scope->getSubScope($scopeUnitTag);
                 // Fetch ObjectRefs to each related entity...
                 $fetchedObjectRefs = array();
                 $hasTerminatedObjects |= $givenObjectRef->fetchRelatedObjectRefsOfEntity($mySQLi, $otherEntity, $queryContext, $subScope, $fetchedObjectRefs);
                 // ...and then fetch each non-terminated entity.
                 foreach ($fetchedObjectRefs as $fetchedObjectRef) {
                     $this->fetchObjects($fetchedObjectRef->getEntity(), $fetchedObjectRef->getId(), $queryContext, $subScope, $skipBinaries, $domDoc, $xmlElement, $xmlElementsWithState, $allFetchedObjects);
                 }
             }
         }
     }
     return $hasTerminatedObjects;
 }