Ok, (I think) I get it now.
What I have done is to take the getaccordion function which generates the vertical menu as a guide, and use this logic, removing any unecessary functionality and also filtering by the product id.
Seems to give me what I need, thanks for the advice.