private List<String> collectStreamIds(StateElement stateElement,
                                          List<String> streamIds) {

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