public static function findCommonPath($directories)
  {
    while(count($directories) !== 1) {
      usort($directories, function($a, $b) {
        return strlen($b) - strlen($a);
      });
      $directories[0] = dirname($directories[0]);
      $directories = array_unique($directories);
    }
    return reset($directories);
  }