def findval(elems, key):
    """Help function for looking up values in the lmf."""
    def iterfindval():
        for form in elems:
            att = form.get("att", "")
            if att == key:
                yield form.get("val")
        yield ""

    return next(iterfindval())