private void recalculateDependencies(final String var) {
        final VariableState state = Objects.requireNonNull(get(var));
        final Set<String> newNeeds;
        if (state.formula == null) {
            newNeeds = Collections.emptySet();
        } else {
            newNeeds = state.formula.getNeededVariables();
        }
        for (String v : state.needs) {
            if (!newNeeds.contains(v)) {
                final VariableState neededState = Objects.requireNonNull(get(v));
                neededState.isNeededBy.remove(var);
                if (neededState.isNeededBy.isEmpty() && neededState.formulaString == null) {
                    variableStateMap.remove(v);
                }
            }
        }
        for (String v : newNeeds) {
            if (!state.needs.contains(v)) {
                VariableState neededState = get(v);
                if (neededState == null) {
                    put(v, null);
                    neededState = Objects.requireNonNull(get(v));
                }
                neededState.isNeededBy.add(var);
            }
        }
        state.needs.clear();
        state.needs.addAll(newNeeds);
    }
Calculates a set of all variables which are needed (directly or indirectly) to calculate the given vars
main/src/main/java/cgeo/geocaching/utils/formulas/VariableMap.java