public static function setByPath(&$subject, array $path, $value)
    {
        $ptr = & $subject;
        foreach ($path as $key) {
            if (is_object($ptr)) {
                if (!isset($ptr->$key)) {
                    $ptr->$key = array();
                }
                $ptr = & $ptr->$key;
            } elseif (is_array($ptr)) {
                if (!isset($ptr[$key])) {
                    $ptr[$key] = array();
                }
                $ptr = & $ptr[$key];
            }
        }
        $ptr = $value;
        return $subject;
    }