Check if query is defined in old_path, since it might be None (e.g.
from a navigation_tree_query)