ZigBee is a standard which is considered to be suitable for wireless sensor networks. In ZigBee, a device is said to join a network if it can obtain a network address from a parent device. Devices calculate addresses for their child devices by a distributed address assignment scheme. This assignment is easy to implement, but it restricts the number of children of a device and the depth of the network. We observe that if one uses the random formation policy specified in ZigBee, the utilization of the address pool will be very low. Those devices that can not receive network addresses will be isolated from the network and become orphan nodes. In this paper, we model the orphan problem by two subproblems: the bounded-degree-and-depth tree formation (BDDTF) problem and the enddevice maximum matching (EDMM) problem. We then present solutions to these problems. The results can be applied to network formation in ZigBee networks.