Updated to support parent/child relations (thanks @HonzaKral)