   defp parse_stream(stream) do
     { metadata, _ } = drop_until_meta(stream) |> Geolix.Decoder.decode()
     metadata        = HashDict.new(metadata)
-    metadata        = HashDict.put(metadata, "node_byte_size", div(HashDict.get(metadata, "record_size", 0), 4))
+    metadata        = HashDict.put(metadata, "node_byte_size", div(HashDict.fetch!(metadata, "record_size"), 4))
     metadata        = HashDict.put(
       metadata, "search_tree_size",
-      HashDict.get(metadata, "node_count", 0) * HashDict.get(metadata, "node_byte_size", 0))
+      HashDict.fetch!(metadata, "node_count") * HashDict.fetch!(metadata, "node_byte_size"))
 
-    { metadata, {} }
+    #ip = {207,  97, 227, 245} # elixir-lang.org
+    ip = {108, 168, 255, 243} # maxmind.com
+
+    case parse_lookup_tree(ip, stream, metadata) do
+      0   -> IO.puts "Nothing found!"
+      ptr ->
+        ptr = ptr - HashDict.fetch!(metadata, "node_count") - 16
+        IO.puts "ptr: #{ptr} => " <> inspect(stream |> drop_until_data(metadata) |> Geolix.Decoder.decode(ptr))
+    end
+
+    { metadata, nil }
+  end
+
+  defp parse_lookup_tree(ip, stream, metadata) do
+    start_node = 96
+    #start_node = get_start_node(32, metadata, stream)
+
+    parse_lookup_tree_bitwise(ip, 0, 32, start_node, stream, metadata)
+  end
+
+  defp parse_lookup_tree_bitwise(ip, bit, bit_count, node, stream, metadata) when bit < bit_count do
+    if node >= HashDict.fetch!(metadata, "node_count") do
+      parse_lookup_tree_bitwise(nil, nil, nil, node, nil, metadata)
+    else
+      temp_bit = 0xFF &&& elem(ip, bit >>> 3)
+      node_bit = 1 &&& (temp_bit >>> 7 - rem(bit, 8))
+      node     = read_node(node, node_bit, stream, metadata)
+
+      parse_lookup_tree_bitwise(ip, bit + 1, bit_count, node, stream, metadata)
+    end
+  end
+  defp parse_lookup_tree_bitwise(_, _, _, node, _, metadata) do
+    node_count = HashDict.fetch!(metadata, "node_count")
+
+    cond do
+      node >  node_count -> node
+      node == node_count -> 0
+      true ->
+        IO.puts "Invalid node below node_count: #{node}"
+        0
+    end
   end
 
   defp drop_until_meta(stream) do

      Enum.drop(stream, 1) |> drop_until_meta()
    end
  end
end

defmodule Geolix.Database do
  use Bitwise, only_operators: true

  @metadata_marker <<171, 205, 239>> <> "MaxMind.com"

  @doc """
