added check for tree->ready in search/3