encapsulated tree search into class, added to utils.py