public static <T extends Comparable<T>> BasicNode<T> getParentNodeOrNull(
      BasicNode<T> root,
      T valueToSearch) {
    if (null == root || null == valueToSearch) {
      throw new IllegalArgumentException("Root or value to be inserted can not be null.");
    }

    if (root.getValue().equals(valueToSearch)) {
      return null;
    }

    Queue<BasicNode<T>> nodes = new LinkedList<BasicNode<T>>();
    nodes.add(root);
    //TODO(anupam): Implement using InOrder traversal as the nodes in next level are added to the
    // queue even if the current level has the node to be searched.
    while (!nodes.isEmpty()) {
      BasicNode<T> node = nodes.poll();
      if (node.hasLeft()) {
        if (node.getLeft().getValue().equals(valueToSearch)) {
          return node;
        }
        nodes.add(node.getLeft());
      }
      if (node.hasRight()) {
        if (node.getRight().getValue().equals(valueToSearch)) {
          return node;
        }
        nodes.add(node.getRight());
      }
    }
    return null;
  }