for (AccountTransaction transaction : transactions) {
if (transaction.getInvestment() != null) {
InvestmentTransaction investmentTransaction = transaction.getInvestment();
if (investmentTransaction != null) {
Investment investment = investmentTransaction.getInvestment();
InvestmentStatus status = investments.get(investment);
if (status == null) {
status = new InvestmentStatus(this, investment);
investments.put(investment, status);
}
status.add(transaction);
}
}
}
return investments.values();
}