private List<StreamHandler> collectStreamHanders(StateElement stateElement,
                                                     List<StreamHandler> streamHandlers) {

        if (stateElement instanceof LogicalStateElement) {
            collectStreamHanders(((LogicalStateElement) stateElement).getStreamStateElement1(), streamHandlers);
            collectStreamHanders(((LogicalStateElement) stateElement).getStreamStateElement2(), streamHandlers);
        } else if (stateElement instanceof CountStateElement) {
            collectStreamHanders(((CountStateElement) stateElement).getStreamStateElement(), streamHandlers);
        } else if (stateElement instanceof EveryStateElement) {
            collectStreamHanders(((EveryStateElement) stateElement).getStateElement(), streamHandlers);
        } else if (stateElement instanceof NextStateElement) {
            collectStreamHanders(((NextStateElement) stateElement).getStateElement(), streamHandlers);
            collectStreamHanders(((NextStateElement) stateElement).getNextStateElement(), streamHandlers);
        } else if (stateElement instanceof StreamStateElement) {
            BasicSingleInputStream basicSingleInputStream = ((StreamStateElement) stateElement)
                    .getBasicSingleInputStream();
            streamHandlers.addAll(basicSingleInputStream.getStreamHandlers());
        }
        return streamHandlers;
    }
Input stream that handle states in query
modules/siddhi-query-api/src/main/java/io/siddhi/query/api/execution/query/input/stream/StateInputStream.java