def find_output_node(nodetree):
    """
    Get first output node that has incoming links.
    """
    for n in nodetree.nodes:
        if n.type.startswith('OUTPUT'):
            for inp in n.inputs:
                if inp.is_linked:
                    return n
    return None