protected static function collapseDotFolder($root, $part, &$canonicalParts)
    {
        if ('.' === $part) {
            return;
        }
        // Collapse ".." with the previous part, if one exists
        // Don't collapse ".." if the previous part is also ".."
        if ('..' === $part && count($canonicalParts) > 0
            && '..' !== $canonicalParts[count($canonicalParts) - 1]
        ) {
            array_pop($canonicalParts);
            return;
        }
        // Only add ".." prefixes for relative paths
        if ('..' !== $part || '' === $root) {
            $canonicalParts[] = $part;
        }
    }