diff --git a/Tools/PyUtils/python/scripts/diff_root_files.py b/Tools/PyUtils/python/scripts/diff_root_files.py
index d3aaca09841e6603f70d35da2887d8cf4e49ec7f..1e7a6fbfe1dc611653a33023469be0de27771718 100644
--- a/Tools/PyUtils/python/scripts/diff_root_files.py
+++ b/Tools/PyUtils/python/scripts/diff_root_files.py
@@ -261,7 +261,7 @@ def main(args):
             read_old = True
             read_new = True
 
-            if (args.order_trees and d_old[-1] == d_new[-1]) or d_old == d_new:
+            if (args.order_trees and d_old and d_new and d_old[-1] == d_new[-1]) or d_old == d_new:
                 n_good += 1
                 continue