# Generic Tree Level Order Traversal
## Problem Statement
A generic tree is a hierarchical data structure consisting of nodes, where each node has a parent (except for the root) and zero or more children. Unlike binary trees, there is no restriction on the number of children a node can have. A tree with $n$ nodes will have exactly $n-1$ edges.
You are given a tree with $n$ nodes, numbered from $1$ to $n$. Node $1$ is considered the root of the tree. Your task is to perform a level order traversal (also known as Breadth-First Search or BFS traversal) of the tree.
In a level order traversal, all nodes at depth $k$ are visited before any node at depth $k+1$. The order of nodes within the same depth can be arbitrary.
## Input Format
- The first line contains a single integer $n$ ($1 \le n \le 10^5$), representing the number of nodes in the tree.
- The next $n-1$ lines each contain two integers $u$ and $v$ ($1 \le u, v \le n$), indicating an undirected edge between node $u$ and node $v$.
## Output Format
Print the nodes level by level. Each level's nodes should be printed on a new line, separated by spaces. The order of nodes within a level can be arbitrary.
## Sample Test Cases
### Sample Input 1
```
5
1 2
2 3
3 4
4 5
```
### Sample Output 1
```
1
2
3
4
5
```
### Sample Input 2
```
7
1 2
1 3
1 4
2 5
2 6
4 7
```
### Sample Output 2
```
1
2 3 4
5 6 7
```
## Constraints
- $1 \le n \le 10^5$
- $1 \le u, v \le n$
- The given input describes a valid tree structure.
- Time limit: 1 second
- Memory limit: 256 MB
## Explanation
### Sample 1:
The tree is a path: $1 - 2 - 3 - 4 - 5$. Node $1$ is the root.
- Depth 0: Node $1$
- Depth 1: Node $2$
- Depth 2: Node $3$
- Depth 3: Node $4$
- Depth 4: Node $5$
### Sample 2:
The tree has $1$ as the root, with children $2, 3, 4$. Node $2$ has children $5, 6$. Node $4$ has child $7$.
- Depth 0: Node $1$
- Depth 1: Nodes $2, 3, 4$. The sample output shows them sorted by ID, i.e., $2, 3, 4$. Other valid orderings for this level include $2, 4, 3$ or $3, 2, 4$, etc.
- Depth 2: Nodes $5, 6, 7$. The sample output shows them sorted by ID, i.e., $5, 6, 7$. Other valid orderings for this level include $5, 7, 6$ or $6, 5, 7$, etc.
Loading problem statement...