def cited_names_from_aux_file(stream):
    """Parse a LaTeX ".aux" file and generate a list of names cited according to
    LaTeX ``\\citation`` commands. Repeated names are generated only once. The
    argument should be a opened I/O stream.

    """
    cited = set()

    for line in stream:
        if not line.startswith(r'\citation{'):
            continue

        line = line.rstrip()
        if line[-1] != '}':
            continue # should issue a warning or something

        entries = line[10:-1]

        for name in entries.split(','):
            name = name.strip()

            if name not in cited:
                yield name
                cited.add(name)