private static bool BagCanContain(string _ /*containerBagName*/, IReadOnlyCollection <BagReference> containerBagReferences, string soughtBagName, IReadOnlyDictionary <string, List <BagReference> > bagRelationships)
        {
            if (containerBagReferences.Count == 0)
            {
                return(false);
            }

            foreach (var containerContainerBagRef in containerBagReferences)
            {
                if (containerContainerBagRef.Name == soughtBagName)
                {
                    return(true);
                }
                if (ContainsSoughtBagName.ContainsKey(containerContainerBagRef.Name))
                {
                    return(true);
                }
                if (BagCanContain(containerContainerBagRef.Name, bagRelationships[containerContainerBagRef.Name], soughtBagName, bagRelationships))
                {
                    ContainsSoughtBagName[containerContainerBagRef.Name] = true;
                    return(true);
                }
            }

            return(false);
        }
        public static int GetNumberOfBagsWhichCanContain(string soughtBagName, Dictionary <string, List <BagReference> > bagRelationships)
        {
            ContainsSoughtBagName.Clear();

            foreach (var bagRelationship in bagRelationships)
            {
                if (bagRelationship.Key == soughtBagName)
                {
                    continue;
                }
                if (ContainsSoughtBagName.ContainsKey(bagRelationship.Key))
                {
                    continue;
                }
                if (BagCanContain(bagRelationship.Key, bagRelationship.Value, soughtBagName, bagRelationships))
                {
                    ContainsSoughtBagName[bagRelationship.Key] = true;
                }
            }

            return(ContainsSoughtBagName.Count);
        }