py/graph: use 2.6 compatible check for set membership