class PathEncoder {

    @Nonnull
    // length is the length in bits. For example ({1},8) is fine
    // First bit is MOST SIGNIFICANT
    private static byte[] decodeBinaryPath(byte[] encoded, int bitlength) {
        byte[] path = new byte[bitlength];

        for (int k = 0; k < bitlength; k++) {
            int nbyte = k / 8;
            int offset = k % 8;

            if (((encoded[nbyte] >> (7 - offset)) & 0x01) != 0) {
                path[k] = 1;
            }
        }

        return path;
    }

    private  PathEncoder();

}