[Working] convert BST into a generic search algorithm