Map<Object, Object> prefsForItems = new FastMap<Object, Object>();
for (User user : users) {
userMap.put(user.getID(), user);
Preference[] prefsArray = user.getPreferencesAsArray();
for (Preference preference : prefsArray) {
Item item = preference.getItem();
Object itemID = item.getID();
itemMap.put(itemID, item);
List<Preference> prefsForItem = (List<Preference>) prefsForItems.get(itemID);
if (prefsForItem == null) {
prefsForItem = new ArrayList<Preference>();
prefsForItems.put(itemID, prefsForItem);