Implement the function count_valid_splits(n, edges, colors) which calculates the number of valid ways to split a graph into two groups based on certain color constraints.
Functionality Requirements:
The function should take three parameters:
An integer n representing the number of nodes in the graph (1 ≤ n ≤ 100000).
A list of tuples edges where each tuple (a, b) represents an edge connecting node a to node b. The list size should be n-1, forming a connected tree.
A list colors of length n, where each element is either 0 (color A) or 1 (color B) representing the color of the corresponding node.
The function should return an integer representing the number of valid ways to split the tree into two groups based on the color constraints, calculated modulo 1000000007.
Input/Output Requirements:
Input:
n (1 ≤ n ≤ 100000): Integer representing the number of nodes in the tree.
edges: A list of tuples where each tuple (a, b) represents an undirected edge between node a and node b. The edges should satisfy that len(edges) == n - 1.
colors: A list of integers of length n, where each integer is either 0 or 1.
Output:
The function should return an integer, which is the number of valid splits modulo 1000000007.
Deliverable:
The solution must be written in a file called /app/solution.py and should include the implementation of the count_valid_splits function described above.