# File lib/geoip.rb, line 483
  def each_by_ip offset = 0, ipnum = 0, mask = nil, &callback
    mask ||= 1 << (@ip_bits-1)

    # Read the two pointers and split them:
    record2 = atomic_read(@record_length*2, @record_length*2*offset)
    record1 = record2.slice!(0, @record_length)

    # Traverse the left tree
    off1 = le_to_ui(record1.unpack('C*'))
    val = off1 - @database_segments[0]
    if val >= 0
      yield(ipnum, val > 0 ? read_record(ipnum.to_s, ipnum, val) : nil) 
    elsif mask != 0
      each_by_ip(off1, ipnum, mask >> 1, &callback)
    end

    # Traverse the right tree
    off2 = le_to_ui(record2.unpack('C*'))
    val = off2 - @database_segments[0]
    if val >= 0
      yield(ipnum|mask, val > 0 ? read_record(ipnum.to_s, ipnum, val) : nil)
    elsif mask != 0
      each_by_ip(off2, ipnum|mask, mask >> 1, &callback)
    end
  end