Can you provide more specific information about what you are trying to do and the problems you currently face?
Is this a homework project, or something you are doing at work?
Is it meant to be a full-blown implementation of the Hierarchical token bucket algorithm?
e.g. a Linux kernel module, or a standalone program/service that will actually affect/shape network traffic/bandwidth?
Or is this just a simulation that uses more abstract means to demonstrate the principles of the algorithm?
What programming language/s are you using to implement this?
What kind of conditions/specifications have been given for the project?
Do you have any snippets of problematic code?
The more information you give about the problem, the more likely it is that someone here will be able to help you!