code: public static int getRowCount(GridPane gridPane) {
      return gridPane.getChildren().stream().mapToInt(n -> {
        Integer row = GridPane.getRowIndex(n);      // default: 0
        Integer rowSpan = GridPane.getRowSpan(n);   // default: 1
        return (row == null ? 0 : row) + (rowSpan == null ? 0 : rowSpan - 1);
      }).max().orElse(-1);
    }
docs: Returns the amount of rows of a given {@code gridPane}, if present, -1 else.