private void recalculate(final String var) {
        final VariableState state = get(var);
        if (state == null) {
            return;
        }
        state.state = State.OK;
        final List<List<String>> cyclesFound = new ArrayList<>();
        recalculate(state, var, true, new LinkedList<>(), cyclesFound);

        if (!cyclesFound.isEmpty()) {
            final Set<String> markError = new HashSet<>();
            for (List<String> cycle : cyclesFound) {
                int idx = 0;
                for (String cv : cycle) {
                    final VariableState s = Objects.requireNonNull(get(cv));
                    s.state = State.CYCLE;
                    s.result = null;
                    s.error = FormulaException.getUserDisplayableMessage(FormulaException.ErrorType.CYCLIC_DEPENDENCY, getCyclicString(cycle, idx++));
                    markError.addAll(s.isNeededBy);
                }
            }
            for (String me : markError) {
                markError(me);
            }
        }
    }
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