public void getPossiblePositions(
      Position position, Node<Position> parent, int dist, int heightLimit, int jumpLimit) {
    if (dist <= 0) {
      return;
    }

    List<Position> possiblePositions = new ArrayList<Position>();

    if (position.getX() > 0) {
      possiblePositions.addAll(
          getPossiblePositionsAt(position.getX() - 1, position.getZ(), heightLimit));
    }
    if (position.getX() < getLength()) {
      possiblePositions.addAll(
          getPossiblePositionsAt(position.getX() + 1, position.getZ(), heightLimit));
    }
    if (position.getZ() > 0) {
      possiblePositions.addAll(
          getPossiblePositionsAt(position.getX(), position.getZ() - 1, heightLimit));
    }
    if (position.getZ() < getDepth()) {
      possiblePositions.addAll(
          getPossiblePositionsAt(position.getX(), position.getZ() + 1, heightLimit));
    }

    for (Position possiblePosition : possiblePositions) {
      if (position.getY() == possiblePosition.getY()) {
        Node<Position> child = parent.addChild(possiblePosition, 1);

        if (child != null) {
          getPossiblePositions(possiblePosition, child, dist - 1, heightLimit, jumpLimit);
        }
      } else if (Math.abs(position.getY() - possiblePosition.getY()) <= jumpLimit) {
        Node<Position> child = parent.addChild(possiblePosition, 1 + jumpLimit);
        if (child != null) {
          getPossiblePositions(
              possiblePosition, child, dist - (1 + jumpLimit), heightLimit, jumpLimit);
        }
      }
    }
  }
  @Test
  public void getPositionTreeTest() {
    int length = 10;
    int height = 5;
    int depth = 10;

    Battlefield battlefield = new Battlefield(length, height, depth, 2);

    for (int i = 0; i < length; i++) {
      for (int j = 0; j < depth; j++) {
        battlefield.addBattlefieldElement(i, 0, j, BattlefieldElement.BattlefieldElementType.BLOC);
      }
    }

    Position originPoint = new Position(1, 0, 1);

    int dist = 3;
    int heightLimit = 2;
    int jumpLimit = 1;

    Tree<Position> result = battlefield.getPositionTree(originPoint, dist, heightLimit, jumpLimit);
    // log.debug(" TEST 1 ");
    // log.debug("     {} : {}", result.getRoot().getData().toString(),
    // result.getRoot().getDistanceFromTop());
    // log.debug("{} children", result.getRoot().getChildren().size());
    for (Node<Position> child : result.getRoot().getChildren()) {
      // log.debug("   ->{} : {}", child.getData().toString(), child.getDistanceFromTop());
      for (Node<Position> child2 : child.getChildren()) {
        // log.debug("  -->{} : {}", child2.getData().toString(), child2.getDistanceFromTop());
        for (Node<Position> child3 : child2.getChildren()) {
          // log.debug(" --->{} : {}", child3.getData().toString(), child3.getDistanceFromTop());
          for (Node<Position> child4 : child3.getChildren()) {
            // log.debug("---->{} : {}", child4.getData().toString(), child4.getDistanceFromTop());
          }
        }
      }
    }

    List<Position> positionList = result.getAllElements();
    for (Position pos : positionList) {
      // log.debug("{}",pos.toString() );
    }
  }