MatchResultImpl () { if (previousResults.isEmpty()) { return null; } else { int index = previousResults.size() - 1; MatchResultImpl result = previousResults.get(index); // may contain nulls while (result == null && index > 0) { index--; result = previousResults.get(index); } return result; } }