Plagiarized programming assignment - How to proceed
It's hard to judge whether your specific situation constitutes plagiarism, since copying "structure" has room for a gray area.

From what you've said though, I personally would take it to the professor.  As someone who has graded student coding work many times in the past, I can say I've definitely developed a feel for when code is copied, and it's usually very easy to check.  Every individual has a signature way of doing things that emerges when enough time is spent looking at their work.

Go in and say you intended to use it as a reference, but upon reflection without the looming deadline you feel like you overdid it, to the point of the work being too close to unoriginal.  Offer to redo it, but be prepared to accept whatever the professor says.  Personally, I can say I would be totally receptive to a student who owned up like that, but obviously there are no guarantees.

Unequivocally though, the worst-case scenario is that the professor figures it out on their own and agrees that it's plagiarism.  The fact that it's a previous student just ups the chances of that.  Plus your own gut is telling you you did something wrong, or you wouldn't be here asking us about it.

Good luck!

Edit: It's also worth consulting your syllabus.  It's possible there are explicit guidelines laid out for dealing with outside code that you should be very aware of before deciding and/or talking to your professor.