Added support for joins which do not necessarily follow one after the other in a hierarchical order