def get_node_list(current_node, direction='down'):
    """
    Returns a list with the content of all connected nodes starting from
    <current_node>. Returns <None> if the node does not exist. If direction
    is <down> follows the "next" link, if direction is <up> follows the
    "previous" link.

    Note: depending on the way the nodes are linked, some nodes may not be
          returned or there may be an infinite loop.
    """
    # Check if it a valid node
    if (current_node is None):
        return None

    # Add the content of the current node
    node_list = [current_node.get_data()]

    # Loop until the end of the node chain (up)
    if (direction == 'up'):

        current_node = current_node.get_previous()
        while (current_node is not None):

            # Append the content of the current node and move to the next node
            node_list.append(current_node.get_data())
            current_node = current_node.get_previous()

        node_list.reverse()

    # Loop until the end of the node chain (down)
    else:

        current_node = current_node.get_next()
        while (current_node is not None):

            # Append the content of the current node and move to the next node
            node_list.append(current_node.get_data())
            current_node = current_node.get_next()

    return node_list