public void visitNeighbour(AStarNode origin, int x, int y, int z) {
    int costFromStart = origin.getCostFromStart() + goal.getNodeCost(origin, x, y, z);
    int costToGoal = goal.distanceToGoal(x, y, z);
    int totalCost = costFromStart + costToGoal;

    // Check if on open/closed list
    // If yes, check if new path is more efficient (lower f value)
    // and update path if so.
    AStarNode foundNode = openList.findOpenNode(x, y, z);
    boolean foundCheaperPath = false;
    if (foundNode != null) {
      if (totalCost < foundNode.getTotalCost()) {
        foundCheaperPath = true;
        openList.removeNodeFromOpenList(foundNode);
      }
    } else {
      foundNode = closedList.findClosedNode(x, y, z);
      if (foundNode != null) {
        if (totalCost < foundNode.getTotalCost()) {
          foundCheaperPath = true;
          closedList.removeNodeFromClosedList(foundNode);
        }
      } else {
        // Node not found in open and closed list, thus put a
        // new one on the open list.
        foundNode = map.nodeAt(x, y, z);
        foundCheaperPath = true;
      }
    }

    if (foundCheaperPath) {
      foundNode.initialize(origin, costFromStart, costToGoal, totalCost, x, y, z);
      openList.addNodeToOpenList(foundNode);
    }
  }