adding algorithm for binary tree serialization/deserilization