protected int findInCol(TemplateModel target,
final int allowedRangeStart, final int allowedRangeEnd)
throws TemplateModelException {
if (allowedRangeEnd < 0) return -1;
TemplateModelIterator it = m_col.iterator();
int foundAtIdx = -1; // -1 is the return value for "not found"
int idx = 0;
searchItem: while (it.hasNext()) {
if (idx > allowedRangeEnd) break searchItem;
TemplateModel current = it.next();
if (idx >= allowedRangeStart) {
if (modelsEqual(current, target, m_env)) {
foundAtIdx = idx;
if (m_dir == 1) break searchItem; // "find first"
// Otherwise it's "find last".