def head(task):
    """Return the top level node of a task."""

    if istask(task):
        return task[0]
    if isinstance(task, list):
        return list
    return task
Return the top level node of a task.
src/flash/core/serve/dag/rewrite.py