class PathUtil {

	public static String parentPath(String path) {
		path = fix(path);
		if (!path.startsWith("/")) {
			path = "/" + path;
		}
		if (path.equals("/")) {
			return null;
		}
		if (path.matches("^/[^/]{1,}/{0,1}$")) {
			path = "/";
		} else {
			List<String> parentPath = RegexUtil.groups(
					"((/{1}[^/]{1}.*))/{1}[^/]{1,}/{0,1}?", path);
			if (parentPath.size() <= 1) {
				throw new RuntimeException("error: " + parentPath + " " + path);
			}
			path = parentPath.get(1);
		}
		return path;
	}

}