class PathSearch {

    public static List<Chunk> split(String s) {
        int pos = s.indexOf(SLASH);
        if (pos == -1) {
            throw new RuntimeException("path did not start with or contain '/'");
        }
        List<Chunk> list = new ArrayList();
        int startPos = 0;
        int searchPos = 0;
        boolean anyDepth = false;
        while (pos != -1) {
            if (pos == 0) {
                startPos = 1;
                searchPos = 1;
            } else if (s.charAt(pos - 1) == '\\') {
                s = s.substring(0, pos - 1) + s.substring(pos);
                searchPos = pos;
            } else {
                String temp = s.substring(startPos, pos);
                if (temp.isEmpty()) {
                    anyDepth = true;
                } else {
                    list.add(new Chunk(anyDepth, temp));
                    anyDepth = false; // reset                   
                }
                startPos = pos + 1;
                searchPos = startPos;
            }
            pos = s.indexOf(SLASH, searchPos);
        }
        if (startPos != s.length()) {
            String temp = s.substring(startPos);
            if (!temp.isEmpty()) {
                list.add(new Chunk(anyDepth, temp));
            }
        }
        return list;
    }

    public  PathSearch(String path, boolean findAll);

}