recursively detect relation path