private function toObjectArray(\Traversable $value) {
        $class = get_class($value);
        if ($value instanceof \ArrayObject) {
            return new $class($value->getArrayCopy(), $value->getFlags(), $value->getIteratorClass());
        } elseif ($value instanceof \ArrayAccess) {
            $r = new $class;
            foreach ($value as $k => $v) {
                $r[$k] = $v;
            }
            return $r;
        }
        return iterator_to_array($value);
    }