public boolean isEndNode(final Node node){
  return getFirstNode() == node || getLastNode() == node;
}

public boolean isEndNode ( final Node node ) { return getFirstNode ( ) == node || getLastNode ( ) == node ; }
checks if a node is an end node of the way ( i . e . either the first or the last one )
