private void discoverReachable(Pipe rootPipe, Set<Pipe> reachablePipes) {
        if (rootPipe == null || reachablePipes.contains(rootPipe)) {
            return;
        }
        reachablePipes.add(rootPipe);
        List<Pipe> outs = rootPipe.getOutputs();
        if (outs == null) {
            return;
        }
        for (int i = 0; i < outs.size(); i++) {
            discoverReachable(outs.get(i), reachablePipes);
        }
    }