private List<Session> prepareTargetSessions(Session targetSession) { List<Session> sessions = restoreSessions(this.file); Optional<Session> session = tryFind(sessions, isForRequest(targetSession.getRequest())); if (session.isPresent()) { session.get().setResponse(targetSession.getResponse()); } else { sessions.add(targetSession); } return sessions; }