I have recently faced this question in a practical test for a job .
Suppose you are given a flat data structure like this :
**Category** **Name**
You could have a design inspired by Swing TreeModel.
EDIT When I say that, I mean you could use a class implementing a likewise interface; Noticeyou can even go as far as using directly this interface, as Swing is a part of standard JRE and is available everywhere standard Java is avaiable.
Furthermore, as it is an interface (and not a class), it's only a way for you to structure your calls. As a consequence, you can easily use it in a console based application.