rr_graph: Move assert_type_or_none to lib/asserts.py

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
diff --git a/v2x/lib/asserts.py b/v2x/lib/asserts.py
index e11e504..008fbf3 100644
--- a/v2x/lib/asserts.py
+++ b/v2x/lib/asserts.py
@@ -26,6 +26,11 @@
     if not isinstance(obj, cls):
         raise TypeError(msg.format(obj=obj, objcls=type(obj), cls=cls))
 
+def assert_type_or_none(obj, classes):
+    """Raise a type error if obj is not an instance of cls or None."""
+    if obj is not None:
+        assert_type(obj, classes)
+
 def assert_len_eq(l):
     """Check all lists in a list are equal length"""
     # Sanity check