def _get_node(default_factory):
    """
    Create a helper function for getting a node from a deployment.

    :param default_factory: A one-argument callable which is called with the
        requested UUID when no matching node is found in the deployment.
        The return value is used as the result.

    :return: A two-argument callable which accepts a ``Deployment`` or a
             ``DeploymentState`` as the first argument and a ``unicode`` string
             giving a node hostname as the second argument.  It will return a
             node from the deployment object with a matching UUID or it
             will return a value from ``default_factory`` if no matching node
             is found.
    """
    def get_node(deployment, uuid, **defaults):
        node = deployment.nodes.get(uuid)
        if node is None:
            return default_factory(uuid=uuid, **defaults)
        return node
    return get_node