private static List<List<BinaryNode>> calculatePathToLeafs(BinaryNode<Integer> root,
      List<BinaryNode> path) {
    List<List<BinaryNode>> paths = new LinkedList<List<BinaryNode>>();
    if (root == null) {
      return paths;
    } else if (root.getLeft() == null && root.getRight() == null) {
      path.add(root);
      paths.add(path);
      return paths;
    } else {
      path.add(root);
      paths.addAll(calculatePathToLeafs(root.getLeft(), new LinkedList<BinaryNode>(path)));
      paths.addAll(calculatePathToLeafs(root.getRight(), new LinkedList<BinaryNode>(path)));
      return paths;
    }
  }
Recursive algorithm to solve this problem. The complexity order of this algorithm is O(N)
where N is the number of elements in the array in time and space terms.
src/main/java/com/github/pedrovgs/problem38/PathToEveryLeaf.java