private BlockPosition getNextTreeSegment(BlockPosition pos) {
    Block block;

    if (_treeManager.getIsDone() || !_treeManager.getOrigin().equals(pos)) {
      int lowerBound = 0;
      int upperBound = MFRConfig.fruitTreeSearchMaxVertical.getInt();

      Area a =
          new Area(
              pos.copy(), MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), lowerBound, upperBound);

      _treeManager.reset(worldObj, a, HarvestMode.FruitTree, null);
    }

    Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
    while (!_treeManager.getIsDone()) {
      BlockPosition bp = _treeManager.getNextBlock();
      block = worldObj.getBlock(bp.x, bp.y, bp.z);
      IFactoryFruit fruit = fruits.containsKey(block) ? fruits.get(block) : null;

      if (fruit != null && fruit.canBePicked(worldObj, bp.x, bp.y, bp.z)) return bp;

      _treeManager.moveNext();
    }
    return null;
  }
  @Override
  protected boolean activateMachine() {
    BlockPosition targetCoords = getNextTree();

    if (targetCoords == null) {
      setIdleTicks(getIdleTicksMax());
      return false;
    }

    Block harvestedBlock = worldObj.getBlock(targetCoords.x, targetCoords.y, targetCoords.z);
    int harvestedBlockMetadata =
        worldObj.getBlockMetadata(targetCoords.x, targetCoords.y, targetCoords.z);

    IFactoryFruit harvestable = MFRRegistry.getFruits().get(harvestedBlock);

    List<ItemStack> drops =
        harvestable.getDrops(worldObj, _rand, targetCoords.x, targetCoords.y, targetCoords.z);

    ReplacementBlock replacement =
        harvestable.getReplacementBlock(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);

    harvestable.prePick(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);

    if (replacement == null) {
      if (!worldObj.setBlockToAir(targetCoords.x, targetCoords.y, targetCoords.z)) return false;
      if (MFRConfig.playSounds.getBoolean(true)) {
        worldObj.playAuxSFXAtEntity(
            null,
            2001,
            targetCoords.x,
            targetCoords.y,
            targetCoords.z,
            Block.getIdFromBlock(harvestedBlock) + (harvestedBlockMetadata << 12));
      }
    } else {
      if (!replacement.replaceBlock(worldObj, targetCoords.x, targetCoords.y, targetCoords.z, null))
        return false;
    }

    doDrop(drops);

    // TODO: sludge?

    harvestable.postPick(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);

    return true;
  }
  private BlockPosition getNextTree() {
    BlockPosition bp = _areaManager.getNextBlock();
    if (!worldObj.blockExists(bp.x, bp.y, bp.z)) {
      return null;
    }

    Block search = worldObj.getBlock(bp.x, bp.y, bp.z);

    if (!MFRRegistry.getFruitLogBlocks().contains(search)) {
      IFactoryFruit f = MFRRegistry.getFruits().get(search);
      return f != null && f.canBePicked(worldObj, bp.x, bp.y, bp.z) ? bp : null;
    }

    BlockPosition temp = getNextTreeSegment(bp);
    if (temp != null) _areaManager.rewindBlock();

    return temp;
  }