Derives a list of tuples containing
    (module name, prefix, xpath)
    per node in the statement.

def mk_path_list(stmt):
    """Derives a list of tuples containing
    (module name, prefix, xpath)
    per node in the statement.
    """
    resolved_names = []
    def resolve_stmt(stmt, resolved_names):
        if stmt.keyword in ['choice', 'case']:
            resolve_stmt(stmt.parent, resolved_names)
            return
        def qualified_name_elements(stmt):
            """(module name, prefix, name)"""
            return (stmt.i_module.arg, stmt.i_module.i_prefix, stmt.arg)
        if stmt.parent.keyword in ['module', 'submodule']:
            resolved_names.append(qualified_name_elements(stmt))
            return
        else:
            resolve_stmt(stmt.parent, resolved_names)
            resolved_names.append(qualified_name_elements(stmt))
            return
    resolve_stmt(stmt, resolved_names)
    return resolved_names