optimizing tree search - in progress! currently broken