switch from before/after to downward/upward and provide the parent node at each step