private Integer getParentForClosedMsgFlow(int msgId) {
   Integer sameMsgIdLastLog = getParentFromMessageLogs(msgId);
   StatisticsLog lastLog = messageFlowLogs.get(sameMsgIdLastLog);
   while (lastLog.getParentMsgId() > DEFAULT_MSG_ID) {
     Integer parentIndex = getParentFromOpenLogs(lastLog.getParentMsgId());
     if (parentIndex != null) {
       return parentIndex;
     }
     lastLog = messageFlowLogs.get(lastLog.getParentLevel());
   }
   return getParentFromOpenLogs(DEFAULT_MSG_ID);
 }
 /**
  * Closes opened statistics log specified by the componentLevel.
  *
  * @param componentLevel index of the closing statistic log in messageFlowLogs
  * @param endTime endTime of the closing statistics log
  */
 private void closeStatisticLog(int componentLevel, Long endTime) {
   StatisticsLog currentLog = messageFlowLogs.get(componentLevel);
   if (log.isDebugEnabled()) {
     log.debug(
         "Closed statistic log of [ElementId"
             + currentLog.getComponentId()
             + "][MsgId"
             + currentLog.getParentMsgId());
   }
   currentLog.setEndTime(endTime);
   updateParentLogs(currentLog.getParentLevel(), endTime);
 }