Introduce better item getter helper in query.py