fn move_down(focus: &mut Focus) {
    if focus.current_node.is_expanded() {
        focus.move_to_first_child();
        return;
    }

    let original_focus = focus.clone();
    while focus.is_on_last_child_of_parent() && !focus.is_on_top_level() {
        focus.move_to_parent()
    }

    // Don't actually move focus if focus was on very last element.
    if focus.is_on_last_child_of_parent() && focus.is_on_top_level() {
        *focus = original_focus;
        return;
    }

    focus.move_to_next_sibling()
}
// Rules:
// - If current node is primitive, go to next sibling
// - If current node is inlined/collapsed, go to next sibling
// - Otherwise, go to first child
//
// - When going to next sibling, if current node is the
//   last child, go to the next sibling of the parent
//   (and repeat if parent is also last child)
//
// - If actually the last node in the tree, don't modify
//   focus
If current node is primitive, go to next sibling
If current node is inlined/collapsed, go to next sibling
Otherwise, go to first child

When going to next sibling, if current node is the
last child, go to the next sibling of the parent
(and repeat if parent is also last child)

If actually the last node in the tree, don't modify
focus
If current node is primitive go to next sibling If current node is inlined / collapsed go to next sibling Otherwise go to first child When going to next sibling if current node is the last child go to the next sibling of the parent ( and repeat if parent is also last child ) If actually the last node in the tree don ' t modify focus
fn move_down(focus: &mut Focus) {
    if focus.current_node.is_expanded() {
        focus.move_to_first_child();
        return;
    }
    let original_focus = focus.clone();
    while focus.is_on_last_child_of_parent() && !focus.is_on_top_level() {
        focus.move_to_parent()
    }
    // Don't actually move focus if focus was on very last element.
    if focus.is_on_last_child_of_parent() && focus.is_on_top_level() {
        *focus = original_focus;
        return;
    }
    focus.move_to_next_sibling()
}
fn move_down ( focus : & mut Focus ) { if focus . current_node . is_expanded ( ) { focus . move_to_first_child ( ) ; return ; } let original_focus = focus . clone ( ) ; while focus . is_on_last_child_of_parent ( ) && ! focus . is_on_top_level ( ) { focus . move_to_parent ( ) } // Don't actually move focus if focus was on very last element. if focus . is_on_last_child_of_parent ( ) && focus . is_on_top_level ( ) { * focus = original_focus ; return ; } focus . move_to_next_sibling ( ) }
Rules:
 If current node is primitive, go to next sibling
 If current node is inlined/collapsed, go to next sibling
 Otherwise, go to first child
Rules : If current node is primitive go to next sibling If current node is inlined / collapsed go to next sibling Otherwise go to first child
focus
&mut Focus
focus
&mut Focus