Fixed bug in ItemTree (on optimization problems) and added test for it