code: def _get_head_block(self):
          
          if not self.head_block_header:
              block_hash = self.db.get(head_header_key)
              num = self._get_block_number(block_hash)
              self.head_block_header = self._get_block_header(block_hash, num)
              # find header with valid state
              while (
                  not self.db.get(self.head_block_header.state_root)
                  and self.head_block_header.prevhash is not None
              ):
                  block_hash = self.head_block_header.prevhash
                  num = self._get_block_number(block_hash)
                  self.head_block_header = self._get_block_header(block_hash, num)
  
          return self.head_block_header
docs: Get head block header.
  
          :return: