Traversal of binary tree based on c++ data structure