class URIPath {

    public Optional<String> getPart(int index) {
        String leftover = removePartsBefore(path, index);
        if (leftover.isEmpty()) return Optional.empty();

        // Remove the leading slash to find ending slash
        leftover = leftover.substring(1);

        // Remove rest of the path (Ends in the next slash)
        int nextSlash = leftover.indexOf('/');
        if (nextSlash == -1) {
            return Optional.of(leftover);
        } else {
            return Optional.of(leftover.substring(0, nextSlash));
        }
    }

    public  URIPath(String path);

}