cpp implementation of Symmetric Tree