public static boolean isCompatible(Directory directory, Circuit circ, TCPStreamProperties sp,
            boolean forHiddenService) throws TorException {
        RouterImpl[] routeCopy = new RouterImpl[circ.getRouteNodes().length];
        for (int i = 0; i < circ.getRouteNodes().length; ++i) {
            routeCopy[i] = circ.getRouteNodes()[i].getRouter();
        }
        if (forHiddenService) {
            // it is not allowed to use circuits that have already been used for
            // smth else
            if (circ.getStreamHistory() == null) {
                if ((circ.getStreams() == null) 
                        || ((circ.getStreams().size() == 1) && (circ.getServiceDescriptor() != null) && (sp.getHostname().contains(circ.getServiceDescriptor().getURL())))) {
                    return directory.isCompatible(routeCopy, sp, forHiddenService);
                }
            }
        } else {
            // check for exit policies of last node
            if ((circ.getServiceDescriptor() == null) && (!circ.isUsedByHiddenServiceToConnectToIntroductionPoint())) {
                return directory.isCompatible(routeCopy, sp, forHiddenService);
            }
        }
        return false;
    }