class AvlTreeMedian {

  public double find(BinaryNode<Integer> root) {
    if (root == null) {
      throw new IllegalArgumentException("You can't pass a null binary tree to this method.");
    }

    List<BinaryNode<Integer>> sortedElements = binaryTreeInOrder.getIterative(root);
    double median = 0;
    if (sortedElements.size() % 2 == 0) {
      median = (sortedElements.get(sortedElements.size() / 2).getData() + sortedElements.get(
          sortedElements.size() / 2 - 1).getData()) / 2;
    } else {
      median = sortedElements.get(sortedElements.size() / 2).getData();
    }
    return median;
  }

  public  AvlTreeMedian();

}