Use defaultdicts, so the if else statement is gone from all the helper methods. 

See http://docs.python.org/2/library/collections.html#collections.defaultdict