def GetMaxRow(panes, direction, layer):
    """
    GetMaxRow() is an internal function which returns
    the highest layer inside the specified dock.
    """
    
    max_row = 0

    for pane in panes:
        if pane.dock_direction == direction and pane.dock_layer == layer and \
           pane.dock_row > max_row:
            max_row = pane.dock_row
    
    return max_row