Compact tries in Python