tree logic