check parent for null before printing parent