I am using groupby (from itertools) to group objects by a key. It would be very useful for me to be able to group objects by the relation of two consecutive objects or by an object relation to the first object in the current group.
I think it should be done by adding a "relation" keyword to the function, that accept two argument functions that return true or false.
It would also be useful to create a function that enable easily creating relation functions. (Like attrgetter does for keys)