protected function retrieveDirected(Direction $direction, ID $node_id, string $class): \ArrayIterator
    {
        $key = $direction->equals(Direction::in()) ? "from" : "to";
        $direction = (string) $direction;

        $hydrate = function (EncapsulatedEdge $encapsulated): EdgeInterface {
            if(!$encapsulated->hydrated())
                return $this->master->edge($encapsulated->id());
            return $encapsulated->edge();
        };

        $filter_classes = function (EncapsulatedEdge $encapsulated) use ($class): bool {
            return in_array($class, $encapsulated->classes());
        };

        if(!isset($this->$key[(string) $node_id])) { 
            return new \ArrayIterator();
        }
        
        if(empty($class)) {
            return new \ArrayIterator(
                array_map($hydrate, $this->$key[(string) $node_id])
            );
        }
        
        return new \ArrayIterator(
            array_map($hydrate, array_filter($this->$key[(string) $node_id], $filter_classes))
        );
    }