protected static function setValue(&$item, $index, $value, $create = false, &$err = null)
    {
        $err = null;

        $key = array_shift($index);
        
        if (is_array($item) || $item instanceof \Traversable) {
            if (empty($index)) {
                $item[$key] = $value;
                return;
            }
            
            if (!isset($item[$key]) && $create) {
                $item[$key] = $create === 'array' ? [] : (object)[];
            }
            
            if (isset($item[$key])) {
                return static::setValue($item[$key], $index, $value, $create, $err);
            }
        } elseif (is_object($item)) {
            if (empty($index)) {
                $item->$key = $value;
                return;
            }
            
            if (!isset($item->$key) && $create) {
                $item->$key = $create === 'array' ? [] : (object)[];
            }
            
            if (isset($item->$key)) {
                return static::setValue($item->$key, $index, $value, $create, $err);
            }
        } else {
            $err = (object)['var' => gettype($item), 'incomplete' => count($index) + 1];
            return;
        }
        
        $err = (object)['var' => null, 'incomplete' => count($index)];
    }