public static function remove($path, $parent = true)
    {
        $ok = true;
        if (true===self::ensureExists($path)) {
            if (false===@is_dir($path) || true===is_link($path)) {
                return @unlink($path);
            }
            $iterator = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($path),
                \RecursiveIteratorIterator::SELF_FIRST | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS
            );
            foreach($iterator as $item) {
                if (in_array($item->getFilename(), array('.', '..'))) {
                    continue;
                }
                if ($item->isDir()) {
                    $ok = self::remove($item);
                } else {
                    $ok = @unlink($item);
                }
            }
            if ($ok && $parent) {
                @rmdir($path);
            }
            @clearstatcache();
        }
        return $ok;
    }