docstr: Insert a value in the tree.
  
  :param key: The key at which the value will be recorded, must be of the
              same type used by the Serializer
  :param value: The value to record in bytes
  :param replace: If True, already existing value will be overridden,
                  otherwise a ValueError is raised.
docstr_tok: ["Insert","a","value","in","the","tree",".",":","param","key",":","The","key","at","which","the","value","will","be","recorded",",","must","be","of","the","same","type","used","by","the","Serializer",":","param","value",":","The","value","to","record","in","bytes",":","param","replace",":","If","True",",","already","existing","value","will","be","overridden",",","otherwise","a","ValueError","is","raised","."]
code: def insert(self, key, value: bytes, replace=False):
      """Insert a value in the tree.
  
      :param key: The key at which the value will be recorded, must be of the
                  same type used by the Serializer
      :param value: The value to record in bytes
      :param replace: If True, already existing value will be overridden,
                      otherwise a ValueError is raised.
      """
      if not isinstance(value, bytes):
          ValueError("Values must be bytes objects")
  
      with self._mem.write_transaction:
          node = self._search_in_tree(key, self._root_node)
  
          # Check if a record with the key already exists
          try:
              existing_record = node.get_entry(key)
          except ValueError:
              pass
          else:
              if not replace:
                  raise ValueError("Key {} already exists".format(key))
  
              if existing_record.overflow_page:
                  self._delete_overflow(existing_record.overflow_page)
  
              if len(value) <= self._tree_conf.value_size:
                  existing_record.value = value
                  existing_record.overflow_page = None
              else:
                  existing_record.value = None
                  existing_record.overflow_page = self._create_overflow(
                      value
                  )
              self._mem.set_node(node)
              return
  
          if len(value) <= self._tree_conf.value_size:
              record = self.Record(key, value=value)
          else:
              # Record values exceeding the max value_size must be placed
              # into overflow pages
              first_overflow_page = self._create_overflow(value)
              record = self.Record(
                  key, value=None, overflow_page=first_overflow_page
              )
  
          if node.can_add_entry:
              node.insert_entry(record)
              self._mem.set_node(node)
          else:
              node.insert_entry(record)
              self._split_leaf(node)
  
imports: from functools import partial
  from logging import getLogger
  from typing import Optional, Union, Iterator, Iterable
  from .None import utils
  from .const import TreeConf
  from .entry import Record, Reference, OpaqueData
  from .memory import FileMemory
  from .node import Node, LonelyRootNode, RootNode, InternalNode, LeafNode, OverflowNode
  from .serializer import Serializer, IntSerializer
label_desc: Use image node_id 6 for calling the BPlusTree obj's underlying member method code with example usage: obj.insert(key, value, replace) without return types