Generic binary searcher