How do you get to the last world to fight Ansem in Kingdom Hearts do you have to beat Sephiroth or is that an optional battle?

you don't have to beat sephiroth to fight ansem I didn't. I think you have to go to hollow bastion to fight ansem.