def trace_depth(pair, stacks, depth):
    """
    Helper function for tracing base pairs "depth" while building dot bracket notation string

    :param pair: Pair to analyze
    :param stacks: Current pair "stacks"
    :param depth: Current depth of main function
    :return: Depth at which make_dot_notation function should now operate
    """
    for stackPair in stacks[depth]:
        if pair[1].position > stackPair[1].position:
            if pair[0].position < stackPair[1].position:
                depth += 1
                return depth
    return depth