Implement queryAllValidPaths operation
Simplify queryValidPaths query