I'm trying to solve some codility task using recursion in Python.
Can someone check this code and tell me why it returns None? I want to get [4, 5] in the variable called "solution". 
def rec_fun(upstream,downstream):
    if not upstream or not downstream : 
        if upstream : 
            return  upstream
        if downstream: 
            return downstream
    if upstream[0] >downstream[0] : 
        downstream.pop(0)
    else:
        upstream.pop(0)
    rec_fun(upstream,downstream)
def solution(A, B):
    upstream=[]
    downstream=[]
    n=len(A)
    for i in range(0,n) : 
        if B[i]==0:
            upstream.append(A[i])
        else:
            downstream.append(A[i])
    upstream=sorted(upstream)
    downstream=sorted(downstream)
    return rec_fun(upstream,downstream)
A=[4,3,2,1,5]
B=[0,1,0,0,0]
solution =  solution(A, B)
print solution
The output is: output = None, it should be [4, 5].
 
    