def node_neighbors(graph, nid):
    """
    Return de neighbor nodes of the node.
    
    This method is not hierarchical and thus the root node has no effect.
    
    Directed graphs and/or masked behaviour: masked nodes or directed
    nodes not having an edge from source to node will not be returned.
    
    :param graph: Graph to query
    :type graph:  Graph class instance
    :param nid:   node ID to return neighbors for
    :type nid:    :py:int
    """
    
    if nid is None:
        return []
    
    if graph.masked:
        nodes = set(graph.nodes.keys())
        adjacency = set(graph.adjacency[nid])
    else:
        nodes = set(graph.origin.nodes.keys())
        adjacency = set(graph.origin.adjacency[nid])

    return sorted(nodes.intersection(adjacency))