@SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  public boolean add(final E bytes) {
    byte[] array = bytes.toArrayUnsafe();
    if (array.length != byteLength) {
      throw new IllegalArgumentException(
          "Byte array is size " + array.length + " but set is size " + byteLength);
    }
    // Two base cases, size==0 and size==1;
    if (root == null) {
      // size==0 is easy, just add
      root = new Node<>(array, bytes, null);
      size++;
      return true;
    }
    if (root.leafObject != null) {
      // size==1 first check then if no match make it look like n>1
      if (Arrays.compare(array, root.leafArray) == 0) {
        return false;
      }
      Node<E> oldRoot = root;
      root = new Node<>(null, null, new Node[256]);
      root.children[oldRoot.leafArray[0] & 0xff] = oldRoot;
    }
    int level = 0;
    Node<E> current = root;
    do {
      int index = array[level] & 0xff;
      Node<E> next = current.children[index];
      if (next == null) {
        next = new Node<>(array, bytes, null);
        current.children[index] = next;
        size++;
        return true;
      }
      if (next.leafObject != null) {
        if (Arrays.compare(array, next.leafArray) == 0) {
          return false;
        }
        Node<E> newLeaf = new Node<>(null, null, new Node[256]);
        newLeaf.children[next.leafArray[level + 1] & 0xff] = next;
        current.children[index] = newLeaf;
        next = newLeaf;
      }
      level++;

      current = next;

    } while (true);
  }
Create a BytesTrieSet with a fixed length

@param byteLength length in bytes of the stored types
evm/src/main/java/org/hyperledger/besu/collections/trie/BytesTrieSet.java