Created BBTree class to solve the problem by BnB