Fixed the function to find descendants for each node