code: private ImmutableMap<Predicate,ImmutableList<TermType>> extractCastTypeMap(
              Multimap<Predicate, CQIE> ruleIndex, List<Predicate> predicatesInBottomUp,
              ImmutableMap<CQIE, ImmutableList<Optional<TermType>>> termTypeMap, DBMetadata metadata) {
  
          // Append-only
          Map<Predicate,ImmutableList<TermType>> mutableCastMap = Maps.newHashMap();
  
          for (Predicate predicate : predicatesInBottomUp) {
              ImmutableList<TermType> castTypes = inferCastTypes(predicate, ruleIndex.get(predicate), termTypeMap,
                      mutableCastMap,metadata);
  
              mutableCastMap.put(predicate, castTypes);
          }
  
          return ImmutableMap.copyOf(mutableCastMap);
      }
docs: Infers cast types for each predicate in the bottom up order