protected virtual double GetProbability(BDDNode node, SamplingVector samplingVector, Dictionary <BDDNode, double> cache = null)
        {
            if (node.IsOne)
            {
                return(1.0);
            }
            if (node.IsZero)
            {
                return(0.0);
            }

            if (cache == null)
            {
                cache = new Dictionary <BDDNode, double> ();
            }
            else if (cache.TryGetValue(node, out double cached))
            {
                return(cached);
            }

            if (_rmapping[node.Index] is Obstacle obstacle)
            {
                //Console.WriteLine("Probability for " + obstacle.Identifier);
                //Console.WriteLine("Obstacle resolved: " + obstacle.Resolved);
                var v = samplingVector.ContainsKey(obstacle.Identifier) & !obstacle.Resolved ?
                        samplingVector.Sample(obstacle) : 0;
                //Console.WriteLine(v);

                double value = GetProbability(node.Low, samplingVector, cache) * (1 - v)
                               + GetProbability(node.High, samplingVector, cache) * v;
                cache[node] = value;
                return(value);
            }
            else if (_rmapping[node.Index] is DomainProperty domProp)
            {
                var v = samplingVector.ContainsKey(domProp.Identifier) ?
                        samplingVector.Sample(domProp) : 0;

                double value = GetProbability(node.Low, samplingVector, cache) * (1 - v)
                               + GetProbability(node.High, samplingVector, cache) * v;
                cache[node] = value;
                return(value);
            }
            else if (_rmapping[node.Index] is DomainHypothesis domHyp)
            {
                var v = samplingVector.ContainsKey(domHyp.Identifier) ?
                        samplingVector.Sample(domHyp) : 0;

                double value = GetProbability(node.Low, samplingVector, cache) * (1 - v)
                               + GetProbability(node.High, samplingVector, cache) * v;
                cache[node] = value;
                return(value);
            }
            else
            {
                throw new NotImplementedException("Type " + _rmapping[node.Index].GetType() + " is not yet supported.");
            }
        }