My tree solution