fn path_depth(path: &AstPath) -> usize
Calculate the depth of a path (number of components). Used for outer-first ordering: shallower paths (outer queries) come first.