<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def topological(nodes):
 """Return nodes in a topological order."""

    order, enter, state = deque(), set(nodes), {}

    def dfs(node):
        """Visit nodes in depth-first order."""
        state[node] = GRAY
        for parent in nodes.get(node, ()):
            color = state.get(parent, None)
            if color == GRAY:
                raise ValueError('cycle')
            if color == BLACK:
                continue
            enter.discard(parent)
            dfs(parent)
        order.appendleft(node)
        state[node] = BLACK

    while enter:
        dfs(enter.pop())

    return order