def idems(dit):
    """Convenience function for iterating dict-likes.

    If dit.items is defined, call it and return the result.
    Otherwise return dit itself.
    """
    return dit.items() if hasattr(dit, 'items') else dit