Problem with refreshing a jquery UI accordion

Problem with refreshing a jquery UI accordion

Hello,
I have a problem with a jquery UI accordion. The first time the page is displayed, it appears something like this, that is a tree that contains other subtrees recursively. This is ok:

http://awesomescreenshot.com/0dd4ge5gc8

This tree is created by calling a JS function called fillTree().
The problem appears when I call again fillTree() without refresh whole page, the first nodes in tree appears at top-level without the rest of the subtrees not associated with them:

http://awesomescreenshot.com/05e4ge6fdb

In both cases, the tree representation should be the same everytime I call filltree(), but I don't know what could happens with that difference...

NOTE: I clear the main container of the main <div> that contains the tree every time fillTree() enters with a .empty() jQuery function.

Do you know what could be the problem? I know that there must be something related with internal jquery variables that must be reseted, but I don't know which of them are. Can anyone help me?