Listing 9.6 Sequential ray intersection test using a k-d tree 