traverse from bottom-up