public function collateChildren(Closure $criteria, $recursive = true)
    {
        $entity_map = new EntityMap;
        $nested_attribute_types = [ EmbeddedEntityListAttribute::CLASS, EntityReferenceListAttribute::CLASS ];
        foreach ($this->getType()->getAttributes([], $nested_attribute_types) as $attribute) {
            foreach ($this->getValue($attribute->getName()) as $child_entity) {
                if ($criteria($child_entity)) {
                    $entity_map->setItem($child_entity->asEmbedPath(), $child_entity);
                }
                if ($recursive) {
                    $entity_map->append($child_entity->collateChildren($criteria));
                }
            }
        }
        return $entity_map;
    }