parseTreeRelationships function

infer relationship from tree template