class FlowChainLogService {

    public List<FlowChainLog> collectRelatedFlowChains(FlowChainLog flowChain) {
        LOGGER.info("Finding out master flow chain based on chain id {}", flowChain.getFlowChainId());
        FlowChainLog rootFlowChain = collectRootFlowChain(flowChain);
        LOGGER.info("Collecting child flow chains based on master chain id {}", rootFlowChain.getFlowChainId());
        Map<String, FlowChainLog> flowChains = new HashMap<>();
        flowChains.put(rootFlowChain.getFlowChainId(), rootFlowChain);
        collectChildFlowChains(flowChains, rootFlowChain);
        LOGGER.info("Collected flow chain ids for checking: {}", Joiner.on(",")
                .join(flowChains.keySet()));
        return flowChains.values()
                .stream()
                .sorted(comparing(FlowChainLog::getCreated))
                .collect(toList());
    }

}