public static Node replacewithBinding(Node node, Binding b) {
    	if(b == null)
    		return node;
    	
        if (node.isVariable() && b.contains(Var.alloc(node))) {
            Node n = b.get(Var.alloc(node));
            if (n== null) return node; // should not happen!
            if (n.isBlank()) {
                  // we do not support blank nodes
                throw new QueryExecException("Cannot handle Blank Nodes over different graphs.");
            } else {
                return n;
            }
        }
        return node;
    }