class BinaryTreePreOrder {

  public List<BinaryNode> getIterative(BinaryNode root) {
    validateBinaryNode(root);
    List<BinaryNode> result = new LinkedList<BinaryNode>();
    Stack<BinaryNode> stack = new Stack<BinaryNode>();
    stack.push(root);

    while (!stack.isEmpty()) {
      BinaryNode node = stack.pop();
      result.add(node);
      if (node.hasRight()) {
        stack.add(node.getRight());
      }
      if (node.hasLeft()) {
        stack.add(node.getLeft());
      }
    }

    return result;
  }

}