protected static function _normalizePath($originalPath, $alwaysArray, $basePath = '')
    {
        list($prefix, $path, $absolute) = self::_startNormalize($originalPath);
        if (!$absolute && $basePath) {
            list($prefix, $path, $absolute) = self::_startNormalize($basePath.'/'.$originalPath);
        }
        if ($absolute && $path != '') {
            // remove leading '/' for path
            if ($path == '/') {
                $path = '';
            } else {
                $path = substr($path, 1);
            }
        }

        if (strpos($path, './') === false && substr($path, -1) != '.') {
            // if there is no relative path component like ../ or ./, we can
            // return directly the path informations
            if ($alwaysArray) {
                if ($path == '') {
                    return array($prefix, array(), $absolute);
                }

                return array($prefix, explode('/', rtrim($path, '/')), $absolute);
            } else {
                if ($path == '') {
                    return array($prefix, $path, $absolute);
                }

                return array($prefix, rtrim($path, '/'), $absolute);
            }
        }
        $path = explode('/', $path);
        $path2 = array();
        $up = false;
        foreach ($path as $chunk) {
            if ($chunk === '..') {
                if (count($path2)) {
                    if (end($path2) != '..') {
                        array_pop($path2);
                    } else {
                        $path2[] = '..';
                    }
                } elseif (!$absolute) {
                    // for non absolute path, we keep leading '..'
                    $path2[] = '..';
                }
            } elseif ($chunk !== '' && $chunk != '.') {
                $path2[] = $chunk;
            }
        }

        return array($prefix, $path2, $absolute);
    }