private static boolean getDependent(Term term, ArrayList list, ArrayList result) {

	if (term.var == null) {
	    
	    boolean found = false;
	    for (int i=0; i<term.subterms.length; i++) {
		
		if (!getDependent(term.subterms[i], list, result)) {
		    return false;
		}

		if (term.subterms[i].getSort().isHidden()) {
		    found = true;
		    break;
		}
	    }

	    if (found || term.operation.resultSort.isHidden()) {
		// check if term.operation is in the list
		if (list.contains(term.operation)) {
		    if (!result.contains(term.operation)) {
			result.add(term.operation);
		    }
		} else {
		    return false;
		}
	    }
	}

	return true;

    }