public static void moveCaret(final @NotNull Project project, final @NotNull Editor editor, final PsiFile file, int[] direction) {
    PsiElement element = getCurrentPsiElement(editor, file);
    element = getParentWithName(element, new String[]{TD, TH});
    assert element != null;
    PsiElement root = getTablePsiElement(element);
    if (root != null) {
      Pair<List<TableRow>, TableCell> pair = getTableAndPosition(root, element);
      List<TableRow> table = pair.first;
      TableCell cell = pair.second;
      int x = cell.startColumn;
      int y = cell.startRow;

      int newX = x;
      int newY = y;
      do {
        x = newX;
        y = newY;
        if (table.get(newY).get(newX).tag != cell.tag) {
          break;
        }
        newY += direction[0];
        newX += direction[1];
      } while (isInsideTable(table, newY, newX));

      TableCell newCell = table.get(y).get(x);
      XmlTag tag = newCell.tag;
      moveCaretTo(editor, findClosingToken(tag));
    }
  }
public static void moveCaret(final @NotNull Project project, final @NotNull Editor editor, final PsiFile file, int[] direction)