class PathEncoder {

    @Nonnull
    private static byte[] encodeBinaryPath(byte[] path) {
        int lpath = path.length;
        int lencoded = lpath / 8 + (lpath % 8 == 0 ? 0 : 1);

        byte[] encoded = new byte[lencoded];
        int nbyte = 0;

        for (int k = 0; k < lpath; k++) {
            int offset = k % 8;
            if (k > 0 && offset == 0) {
                nbyte++;
            }

            if (path[k] == 0) {
                continue;
            }

            encoded[nbyte] |= 0x80 >> offset;
        }

        return encoded;
    }

    private  PathEncoder();

}