SELECT Y.UserID FROM (

  SELECT @nConsultantID AS UserID

  UNION

  SELECT ConsultantID AS UserID FROM taBranchStructure AS X WHERE (X.LeaderPositionID IN (
    SELECT PositionID FROM taBranchStructure AS A WHERE (A.ConsultantID IN (@pConsultantID))
  )) AND (X.ConsultantID IS NOT NULL)

  UNION

  SELECT ConsultantID AS UserID FROM taBranchStructure AS X WHERE (X.LeaderPositionID IN (
    SELECT PositionID FROM taBranchStructure AS A WHERE (A.ConsultantID IN (
      SELECT ConsultantID FROM taBranchStructure AS X WHERE (X.LeaderPositionID IN (
        SELECT PositionID FROM taBranchStructure AS A WHERE (A.ConsultantID IN (@pConsultantID))
      )) AND (X.ConsultantID IS NOT NULL)
    ))
  )) AND (X.ConsultantID IS NOT NULL)

  UNION

  SELECT ConsultantID AS UserID FROM taBranchStructure AS X WHERE (X.LeaderPositionID IN (
    SELECT PositionID FROM taBranchStructure AS A WHERE (A.ConsultantID IN (
      SELECT ConsultantID FROM taBranchStructure AS X WHERE (X.LeaderPositionID IN (
        SELECT PositionID FROM taBranchStructure AS A WHERE (A.ConsultantID IN (
          SELECT ConsultantID FROM taBranchStructure AS X WHERE (X.LeaderPositionID IN (
            SELECT PositionID FROM taBranchStructure AS A WHERE (A.ConsultantID IN (@pConsultantID))
          )) AND (X.ConsultantID IS NOT NULL)
        ))
      )) AND (X.ConsultantID IS NOT NULL)
    ))
  )) AND (X.ConsultantID IS NOT NULL)

) AS Y
WHERE (Y.UserID IS NOT NULL) AND (Y.UserID > 0)
ORDER BY Y.UserID
