improve same tree solution