public List<BinaryNode> getUsingQueue(BinaryNode root) {
    validateBinaryNode(root);

    List<BinaryNode> result = new LinkedList<BinaryNode>();
    Queue<BinaryNode> queue = new LinkedList<BinaryNode>();
    queue.add(root);
    while (!queue.isEmpty()) {
      BinaryNode binaryNode = queue.remove();
      result.add(binaryNode);
      if (binaryNode.getLeft() != null) queue.add(binaryNode.getLeft());
      if (binaryNode.getRight() != null) queue.add(binaryNode.getRight());
    }
    return result;
  }
Add implementation based on an additional data structure, one queue which implementation is a
LinkedList. What we are going to do is add elements of the tree to the queue and one by one
evaluate it adding more binary nodes to the queue if exist. The complexity order in time terms
is O(N) where N is the number of elements in the tree. The complexity order in space terms is
O(N) where N is the number of elements in the tree because we are going to store every node in
a queue.
src/main/java/com/github/pedrovgs/problem13/BinaryTreeByLevel.java