Genre ça ? :
 
```scala
  def getCloseNodes(origin: nodeInfo, excluded: Set[nodeInfo], numberOfNodes: Int): Seq[nodeInfo] = {
    if (origin == None|| origin.node.path == this.network.path ){
      // If we take as a reference the current node, we only have to retrieve the n first elements of the list without the excluded nodes
      closeNodes.filterNot(excluded contains).take(numberOfNodes)
    } else {
      // Else we just have to compute the distances between the reference and the nodes in memory, sort them, and send the n closest without excluded nodes
      val relativeDistancesSeq = closeNodes.map(node => node.copy(distanceFromSelf = computeDistanceBtw(origin.coordinates,this.coordinates)))
      relativeDistancesSeq.sorted
      relativeDistancesSeq.filterNot(excluded contains).take(numberOfNodes)
    }
  }
```