def factory_key(item):
    """Helper for topological sort of factories.

    :param item: a ``name, factory`` tuple to generate the key for.
    :return: iterable of ``name, factory`` tuples that factory in item
      depends on for construction.
    """
    name, factory = item
    arguments = getattr(factory, 'factory_arguments', None)
    if arguments is None:
        return []
    return arguments.items()
