My ds doesn't do this to go to the bathroom, but he has started sleepwalking. He walked into the hall and stood there, turned on the light in his room and went back to bed, played with toys, talked to us. I usually watch him for a couple minutes to see if he's really awake or still asleep. I would gently redirect to the bathroom and make sure he's not getting overtired.