private ArrayList<Integer> determinePagesOfTermInSelectedChapters(ArrayList<Integer> termTotalPages, ArrayList<Integer> totalPagesInSelectedChapters){
		if(totalPagesInSelectedChapters.size()!=0){
			ArrayList<Integer> termTotalPagesWrapper = new ArrayList<Integer>(termTotalPages); //here to ensure no changes are made to the parameters.
			ArrayList<Integer> totalPagesInSelectedChaptersWrapper = new ArrayList<Integer>(totalPagesInSelectedChapters); //here to ensure no changes are made to the parameters.
			ArrayList<Integer> toRemove = new ArrayList<>();
			for(Integer i: termTotalPagesWrapper){
				boolean wasNotFound = true;
				for(Integer j: totalPagesInSelectedChaptersWrapper){
					if(i.equals(j)){
						wasNotFound = false;
						break;
					}
				}
				if(wasNotFound){
					toRemove.add(i);
				}
			}
			//Remove pages that aren't in the specified chapters.
			for(Integer i:toRemove){
				termTotalPagesWrapper.remove(i);
			}
			return termTotalPagesWrapper;
		}
		//If the second parameter is an empty list just return the first parameter.
		else {
			return termTotalPages;
		}
	}