class GetTheElementInTheMiddleOfTheList {

  public ListNode<Integer> get(ListNode<Integer> list) {
    validateInput(list);

    int size = getListSize(list);
    int middleElementPosition = size % 2 != 0 ? size / 2 : (size / 2) - 1;
    ListNode middleElement = list;
    for (int i = 0; i < middleElementPosition; i++) {
      middleElement = middleElement.getNext();
    }
    return middleElement;
  }

}