@Override public Row next() { // If we've ever seen a row, just defer to input if (sawOne) { return input.next(); } Row result = input.next(); // If we saw a row, mark it as such and defer to input if (result != null) { sawOne = true; return result; } // Our search is at an end; return our answer if (atTable == null || atTable == stopSearchTable) { return null; } // Close the input, shorten our hkey, re-open and try again input.close(); assert atTable.getParentTable() != null : atTable; atTable = atTable.getParentTable(); HKey hkey = getHKeyFromBindings(); hkey.useSegments(atTable.getDepth() + 1); input.rebind(hkey, deep); input.open(); return next(); }