public static function bubble($path, \Closure $comparator)
{
$found = null;
$path = self::normalizeDirectorySeparator($path);
$drive = null;
if (preg_match('~^(\\w:)(.+)~', $path, $parts)) {
$drive = $parts[1];
$path = $parts[2];
}
$pathParts = explode('/', $path);
while (count($pathParts) > 0 && $found === null) {
$path = implode('/', $pathParts);
if ($comparator($path)) {
$found = $path;
}
array_pop($pathParts);
}
if ($drive && $found) {
$found = $drive . $found;
}
return $found;
}