If the key is present in dictionary, remove it and return it's
    value. If it is not present, return None.

def _take(d, key, default=None):
    """
    If the key is present in dictionary, remove it and return it's
    value. If it is not present, return None.
    """
    if key in d:
        cmd = d[key]
        del d[key]
        return cmd
    else:
        return default