You can't call view methods like expandToLevel
in the listener because the viewer is already dealing with an expand and is not designed to deal with another expand while it is doing that.
You could use Display.asyncExec
in the treeExpanded
method to run the expandToLevel
after the expand current has completed.