``if callable(method):`` is better (here and above), and ``collections`` import can be removed.