How to prevent custom walker from creating sub navigation for pages that are not relatives of the current page?

You may find this article I wrote over at WPtuts helpful.

The following example I’ve adapted from that article. It lists all the top leve links, but only explores ancestors of the ‘current’ menu item. Hopefully the logic is clear with the comments:

class WPSE73358_Ancestors_Only_Walker extends Walker_Nav_Menu {

    // Only follow down one branch
    function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {

        // Check if element as a 'current element' class
        $current_element_markers = array( 'current-menu-item', 'current-menu-parent', 'current-menu-ancestor' );
        $current_class = array_intersect( $current_element_markers, $element->classes );

        // If element has a 'current' class, it is an ancestor of the current element
        $ancestor_of_current = !empty($current_class);

        // If this is not the top level nor the current, or ancestor of the current menu item - stop here.
       if ( 0 != $depth &&  !$ancestor_of_current)
           return;

        parent::display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output );
    }
}

Although it extends the Walker_Nav_Menu it is written so that it can extend pretty much any of the Walker classes (including the base class). You may find that the classes need to be changed, or – for instance with posts, it may be more appropriate to use get_post_ancestors() instead.