A 26-year-old man from California has survived surgery after a tapeworm, which has been causing severe headaches, was removed from his brain.