public int calcChildDistance(IBranchPart branch, ParentSearchKey key) {
    Point pos = key.getCursorPos();
    Column2 col = getColumn(branch);
    Chart2 chart = col.getOwnedChart();
    int rowX = col.getLeft();
    int rowWidth = col.getWidth();
    if (pos.x > rowX && pos.x < rowX + rowWidth) {
      if (!chart.hasRows()) {
        int y = chart.getTitle().getFigure().getBounds().y;
        int h = chart.getTitle().getFigure().getBounds().height;
        int childY = key.getFigure().getBounds().y;
        if (childY > y && childY < y + h) return 0;
      }
      Cell2 cell = col.findCell(pos);
      if (cell != null) {
        if (cell.getItems().isEmpty()) return 0;
        int colY = cell.getOwnedRow().getTop();
        int offset = pos.y - colY;
        int index = 0;
        int last = cell.getItems().size() - 1;
        for (Item2 item : cell.getItems()) {
          Rectangle itemBounds = item.getBranch().getFigure().getBounds();
          if (index == 0) {
            if (pos.y < itemBounds.y) return 0;
          }
          if (index == last) {
            if (pos.y > itemBounds.bottom()) return 0;
          }
          if (pos.x < itemBounds.x) return 0;

          Rectangle itemTopicBounds = item.getBranch().getTopicPart().getFigure().getBounds();
          if (pos.x < itemTopicBounds.right()) {
            return offset;
          }
          index++;
        }
        return offset;
      }
    }
    return -1;
  }