Source:
<code>public QuantileDigest(Slice serialized) { SliceInput input = new BasicSliceInput(serialized); byte format = input.readByte(); checkArgument(format == 0, "Invalid format"); maxError = input.readDouble(); alpha = input.readDouble(); if (alpha == 0.0) { ticker = noOpTicker(); } else { ticker = Ticker.systemTicker(); } landmarkInSeconds = input.readLong(); min = input.readLong(); max = input.readLong(); int nodeCount = input.readInt(); int numberOfLevels = MAX_BITS - Long.numberOfLeadingZeros(min ^ max) + 1; double k = 3 * numberOfLevels / maxError; checkArgument(nodeCount <= 2 * k, "Too many nodes in deserialized tree. Possible corruption"); counts = new double[nodeCount]; levels = new byte[nodeCount]; values = new long[nodeCount]; int[] stack = new int[(Integer.highestOneBit(nodeCount - 1) << 1) + 1]; int top = -1; lefts = new int[nodeCount]; rights = new int[nodeCount]; for (int node = 0; node < nodeCount; node++) { byte nodeStructure = input.readByte(); boolean hasRight = (nodeStructure & Flags.HAS_RIGHT) != 0; boolean hasLeft = (nodeStructure & Flags.HAS_LEFT) != 0; <START> byte level = (byte) (toUnsignedInt(nodeStructure) >>> 2); <END> if (hasLeft || hasRight) { level++; } levels[node] = level; if (hasRight) { rights[node] = stack[top--]; } else { rights[node] = -1; } if (hasLeft) { lefts[node] = stack[top--]; } else { lefts[node] = -1; } stack[++top] = node; double count = input.readDouble(); weightedCount += count; counts[node] = count; values[node] = input.readLong(); } checkArgument(nodeCount == 0 || top == 0, "Tree is corrupted. Expected a single root node"); root = nodeCount - 1; nextNode = nodeCount; }</code><technical_language>this clear extracting topmost 6 bits: java (nodeStructure >> 2) & 0b111111</technical_language>

Target:
public QuantileDigest(Slice serialized) { SliceInput input = new BasicSliceInput(serialized); byte format = input.readByte(); checkArgument(format == 0, "Invalid format"); maxError = input.readDouble(); alpha = input.readDouble(); if (alpha == 0.0) { ticker = noOpTicker(); } else { ticker = Ticker.systemTicker(); } landmarkInSeconds = input.readLong(); min = input.readLong(); max = input.readLong(); int nodeCount = input.readInt(); int numberOfLevels = MAX_BITS - Long.numberOfLeadingZeros(min ^ max) + 1; double k = 3 * numberOfLevels / maxError; checkArgument(nodeCount <= 2 * k, "Too many nodes in deserialized tree. Possible corruption"); counts = new double[nodeCount]; levels = new byte[nodeCount]; values = new long[nodeCount]; int[] stack = new int[(Integer.highestOneBit(nodeCount - 1) << 1) + 1]; int top = -1; lefts = new int[nodeCount]; rights = new int[nodeCount]; for (int node = 0; node < nodeCount; node++) { byte nodeStructure = input.readByte(); boolean hasRight = (nodeStructure & Flags.HAS_RIGHT) != 0; boolean hasLeft = (nodeStructure & Flags.HAS_LEFT) != 0; byte level = (byte) ((nodeStructure >>> 2) & 0b111111); if (hasLeft || hasRight) { level++; } levels[node] = level; if (hasRight) { rights[node] = stack[top--]; } else { rights[node] = -1; } if (hasLeft) { lefts[node] = stack[top--]; } else { lefts[node] = -1; } stack[++top] = node; double count = input.readDouble(); weightedCount += count; counts[node] = count; values[node] = input.readLong(); } checkArgument(nodeCount == 0 || top == 0, "Tree is corrupted. Expected a single root node"); root = nodeCount - 1; nextNode = nodeCount; }