Almost always null errors are caused by type problems. This means you are trying to use an Object in a way that is not valid for that type of Object. Most of the time this is caused by , for example, trying to do a comparison operator with an Item’s whose state is NULL.
I’d be willing to bet that one of your members of groupItem is NULL which means l.state > 0
is an error.